NGINX proxy_pass 返回 502 但服务器正在记录 200

NGINX proxy_pass 返回 502 但服务器正在记录 200

我正在尝试添加location /us/castle/knights到这个 nginx 服务器并替换相同 url 上的现有服务器请求。

当我打https://localhost/us/castle/knights我收到 502 错误,但我可以看到请求http://localhost:9000/us/castle/knights响应 200。

为什么我会收到 502 错误?我该如何修复此问题以便请求能够到达代理服务器?

error_log /Users/treggi/Projects/castle/nginx/error.log;
pid /Users/treggi/Projects/castle/nginx/nginx.pid;
worker_processes  1;
daemon off;
events { worker_connections  1024; }
http {
    access_log /Users/treggi/Projects/castle/nginx/access.log;
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;
    server {
        listen 443 ssl;
        server_name localhost;
        ssl_certificate /Users/treggi/Projects/castle/nginx/nginx-selfsigned.crt;
        ssl_certificate_key /Users/treggi/Projects/castle/nginx/nginx-selfsigned.key;
        root /Users/treggi/Projects/castle/packages/castle-frontend/dist/site;
        location /us/api {
            proxy_pass http://localhost:3000/;
        }
        location /us/castle/knights {
            proxy_pass http://localhost:9000/us/castle/knights/;
        }
        location /us/castle {
            alias /Users/treggi/Projects/castle/packages/castle-frontend/dist/site;
            index index.dev.htm;
            try_files $uri $uri/ /index.dev.htm =404;
            autoindex on;
            expires 0;
        }
    }
}

相关内容