I have a server where I want setup a reverse proxy with nginx to handle HTTPS traffic to an app in a docker container. Below is the config file in /etc/nginx/sites-enabled
. It is based on this guide and the ssl setup done automatically by certbot for the default config file.
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;
}
}
This setup fails to properly redirect traffic, though. When I open up example.com/doccano
, only a spinning wheel shows up. It is trying to load resources, but these are not properly forwarded, as /var/log/nginx/error.log
shows below. This is similar to this question, but I am not missing the trailing /
and it still does not work. I opened up port 8000 to check if the app is the problem, but it works fine there. How do I set this up properly?
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/"