NGINX上的502错误网关

时间:2020-05-28 10:01:39

标签: nginx-reverse-proxy bad-gateway

我正在NGINX CENTOS 7上运行React应用程序。服务器运行了一段时间后,我得到了502 Bad网关。尝试了许多不同的配置,但似乎连接超时。我在具有相同configuratin的同一服务器上运行另一个站点,并且该站点始终处于运行状态。到目前为止,我唯一的补救方法是重新启动应用程序。我无法每5分钟检查一次网关故障。我检查了访问日志,发现有一些对php文件的请求不再存在。

upstream my_server {
    server X.X.X.X:5020;
}

server {

    root /var/www/html/####/####-app/build;
    index index.html;
    server_name #####.com www.#####.com;

    access_log /var/log/nginx/#####.com.access.log;
    error_log /var/log/nginx/#####.com.error.log;

    location / {
        proxy_pass http://my_server;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_http_version 1.1;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto http;
        proxy_redirect off;
        proxy_buffering off;
        try_files $uri $uri/ /index.html?/$request_uri;
    }
    location ~ .(aspx|php|jsp|cgi)$ {
        return 410;
    }

}

0 个答案:

没有答案