NGINX反向代理失败并显示404

时间:2019-07-14 05:52:40

标签: nginx

我正在将NGINX设置为反向代理。

详细信息:

nginx -v nginx版本:nginx / 1.14.0(Ubuntu)

以下配置绝对可以正常工作:

server {
        listen 443 ssl;
        listen [::]:443 ssl;

        root /var/www/html;

        index index.html index.htm index.nginx-debian.html;

        server_name 172.31.1.248;

        ssl_certificate /home/ubuntu/SSL/self-public-key.pem;
        ssl_certificate_key /home/ubuntu/SSL/self-private-key.pem;

        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_prefer_server_ciphers on;

        location / {
                try_files $uri $uri/ =404;
        }

        location /pass/ {
                proxy_pass http://172.31.1.137:8000;
        }
}

但是,对于上游块,请求失败并显示404。我已经尝试了两个proxy_pass http://backend;和proxy_pass http://backend/;

upstream backend {
        server 172.31.1.137:8000;
}

server {
        listen 443 ssl;
        listen [::]:443 ssl;

        root /var/www/html;

        index index.html index.htm index.nginx-debian.html;

        server_name 172.31.1.248;

        ssl_certificate /home/ubuntu/SSL/self-public-key.pem;
        ssl_certificate_key /home/ubuntu/SSL/self-private-key.pem;

        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_prefer_server_ciphers on;

        location / {
                try_files $uri $uri/ =404;
        }

        location /pass/ {
                proxy_pass http://backend;
        }
}

0 个答案:

没有答案