我正在使用 Nginx 作为代理来部署应用程序的后端和前端。但是我遇到了错误502 Bad Gateway
,错误信息如下
[错误]:连接到上游时 connect() 失败(111:连接被拒绝),客户端:218.232.234.171,服务器:hms.kict.re.kr,请求:“GET /favicon.ico HTTP/1.1”,上游:“http://172.25.0.2:32000/favicon.ico”,主机:“hms.kict.re.kr”,引荐来源:“https://hms.kict.re.kr/”
我以前从未遇到过这个错误,所以仍然坚持下去。
这是我的nginx.conf
文件
server {
listen 31000;
sendfile on;
default_type application/octet-stream;
keepalive_timeout 65;
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 256;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
location /api/ {
proxy_pass http://dev-api:3000;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
client_max_body_size 1g;
}
location / {
proxy_pass http://dev-web:80;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
client_max_body_size 1g;
}
}