0

I have a service running on Docker on port 3000 inside a Raspberry Pi. I added a reverse proxy on nginx to serve that service.

server {
    listen 80;
    server_name pizza.pi;
location /my-dashboard {
    # Pass requests to the backend service
    proxy_pass http://127.0.0.1:3000;
    proxy_http_version 1.1;

    # WebSocket and other headers
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    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;

    # Ensure proper path forwarding
    rewrite ^/my-dashboard(/.*)$ $1 break;
}

}

When I go to http://pizza.pi/my-dashboard from inside the Pi, I am correctly seeing the service (NextJS) running. However, when I try to access the same URL from another computer on the network, I get 404 and I see the following logs on nginx:

[debug] 16756#16756: *45 test location: "/"
[debug] 16756#16756: *45 using configuration "/"
...
[debug] 16756#16756: *45 http script var: "/my-dashboard"
[debug] 16756#16756: *45 trying to use file: "/my-dashboard" "/var/www/html/my-dashboard"
[debug] 16756#16756: *45 http script var: "/my-dashboard" 
[debug] 16756#16756: *45 trying to use dir: "/my-dashboard" "/var/www/html/my-dashboard"
[debug] 16756#16756: *45 trying to use file: "=404" "/var/www/html=404"  
[debug] 16756#16756: *45 http finalize request: 404, "/my-dashboard?" a:1, c:1
[debug] 16756#16756: *45 http special response: 404, "/my-dashboard?"
[debug] 16756#16756: *45 http set discard body
[debug] 16756#16756: *45 HTTP/1.1 404 Not Found

The service is however accessible on the network if I specify the port http://pizza.pi:3000/my-dashboard but then I don't get any logs on nginx, which tells me that nginx is somehow bypassed in this case (just a guess, as I'm not that familiar with such configs).

I've tried playing around with trailing slashes in the configuration but to no avail.

What am I missing here? How can I get http://pizza.pi/my-dashboard to work from any device on the network?

Andrei V
  • 101

0 Answers0