Score:0

Revese proxy fails to forward requests to port

ca flag
shs

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/"
in flag
https://github.com/doccano/doccano/issues/1878
in flag
Your backend needs to be configured with the proper base url, but that currently seems not to be trivial with doccano. An easier alternative would be to use a subdomain instead.
shs avatar
ca flag
shs
Thanks, this helped me resolve the issue. It is unfortunate that doccano is not easily configurable for such a setup.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.