Revese 代理无法将请求转发到端口

Revese 代理无法将请求转发到端口

我有一台服务器,我想在其中设置一个反向代理,使用 nginx 来处理 docker 容器中应用程序的 HTTPS 流量。下面是配置文件/etc/nginx/sites-enabled。它基于本指南并且 certbot 为默认配置文件自动完成了 ssl 设置。

server {
   listen 80;
   server_name example.com;
   return 301 https://example.com$request_uri;
 }

server {
    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

   location /doccano/ {
        proxy_pass http://localhost:8000/;

        proxy_set_header        Host $host;
        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;
    }
}

但是,此设置无法正确重定向流量。当我打开时example.com/doccano,只显示一个旋转的轮子。它正在尝试加载资源,但这些资源未正确转发,如下/var/log/nginx/error.log所示。这类似于这个问题,但我没有遗漏尾部/,它仍然不起作用。我打开了端口 8000 来检查应用程序是否是问题所在,但它在那里运行正常。我该如何正确设置它?

2023/03/07 09:06:37 [error] 15264#15264: *310 open() "/usr/share/nginx/html/static/_nuxt/c296893.js" failed (2: No such file or directory), client: my_ip_v6, server: , request: "GET /static/_nuxt/c296893.js HTTP/1.1", host: "example.com", referrer: "https://example.com/doccano/"
2023/03/07 09:06:37 [error] 15264#15264: *310 open() "/usr/share/nginx/html/static/_nuxt/b152b18.js" failed (2: No such file or directory), client: my_ip_v6, server: , request: "GET /static/_nuxt/b152b18.js HTTP/1.1", host: "example.com", referrer: "https://example.com/doccano/"
2023/03/07 09:06:37 [error] 15264#15264: *312 open() "/usr/share/nginx/html/static/_nuxt/831ddf8.js" failed (2: No such file or directory), client: my_ip_v6, server: , request: "GET /static/_nuxt/831ddf8.js HTTP/1.1", host: "example.com", referrer: "https://example.com/doccano/"
2023/03/07 09:06:37 [error] 15264#15264: *313 open() "/usr/share/nginx/html/static/_nuxt/6c3c49a.js" failed (2: No such file or directory), client: my_ip_v6, server: , request: "GET /static/_nuxt/6c3c49a.js HTTP/1.1", host: "example.com", referrer: "https://example.com/doccano/"
2023/03/07 09:06:38 [error] 15264#15264: *310 open() "/usr/share/nginx/html/static/_nuxt/b152b18.js" failed (2: No such file or directory), client: my_ip_v6, server: , request: "GET /static/_nuxt/b152b18.js HTTP/1.1", host: "example.com", referrer: "https://example.com/doccano/"
2023/03/07 09:06:38 [error] 15264#15264: *310 open() "/usr/share/nginx/html/static/_nuxt/6c3c49a.js" failed (2: No such file or directory), client: my_ip_v6, server: , request: "GET /static/_nuxt/6c3c49a.js HTTP/1.1", host: "example.com", referrer: "https://example.com/doccano/"

相关内容