Nginx Settings for Rhasspy not working

I am trying the route the rhasspy through nginx and except for the initial page, unable to get proper settings, here is my conf and errors

  location /rhasspy/
  {
    proxy_pass  https://<ip>:<port>/;
    proxy_set_header Host $host:$server_port;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

Error log
2021/10/10 06:33:40 [error] 341#341: *1 open() “/var/lib/nginx/html/settings” failed (2: No such file or directory), client: <ip_add>, server: .duckdns.org, request: “GET /settings HTTP/1.1”, host: “:”, referrer: “https://:/rhasspy”

The main page gets displayed properly - except that Rhasspy logo
image

When I click on the settings link (the three Gear Icons on the left panel), I am greeted with 404 error " 404 Not Found - nginx/1.18.0"
Error log. Not sure why the nginx is looking into its lib folder?

2021/10/10 06:33:27 [error] 341#341: *1 open() "/var/lib/nginx/html/img/logo.png" failed (2: No such file or directory), client: <ip_add>, server: <myserver>.duckdns.org, request: "GET /img/logo.png HTTP/1.1", host: "<myserver>:<port>", referrer: "https://<myserver>:<port>/rhasspy"

I always use the following nginx configuration for a reverse proxy:

location /rhasspy/
{
  proxy_pass  https://<ip>:<port>/;
  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;
  proxy_set_header    X-Forwarded-Host    $host;
  proxy_set_header    X-Forwarded-Port    $server_port;
  proxy_set_header    Host                $host;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "Upgrade";
}

Probably not all of these options are needed for Rhasspy.

Thanks. But it’s not working for me. So I reinstalled nginx from scratch. So now, it has gone 1 step backwards, When i try this https://myPublicURL:port/rhasspy I get the following. The entire page itself is not loading, see the error log below

In the logs I get this

 manju [11/Oct/2021:16:43:30 +0800] "GET /js/alpine.js HTTP/1.1" 404 153 "https://publicip:port/rhasspy/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0" "-"

The direct URL to rhasspy is working fine, hence the Rhasspy itself is working fine but the routing from nginx is not

Well, I have a slightly different setup. I’m using something like this in my nginx.conf for Rhasspy:

http {

    sendfile on;

    server {
        listen 12101 ssl;
        include /etc/nginx/ssl.conf;

        location / {
            proxy_pass http://rhasspy:12101;
            include    common_location.conf;
        }
    }

    server {
        listen 8880 ssl;
        include /etc/nginx/ssl.conf;

        location / {
            ...
        }
    }
}

Note that I don’t use /rhasspy as the root location, but /. This way I access Rhasspy by visiting https://IP:12101.

okay. However, I prefer using the location separation to service different services, like ip/rhasspy - take to rhassppy, ip/esphome take to esphome and so on. Internally with the docker they may be running on same or other machines. This way I don’t need multiple domain names neither open multiple ports in router
So I did some debugging, and it looks strange.

  1. With /rhasspy, i get that malformed page as in my earlier post
  2. If I just configure for the root - then voila - the rhasspy just works fine. So why does this config works and other does not?

Working

  location /
  {
    proxy_pass https://<ip>:<port>/;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host:$server_port;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
  }

Not Working*

  location /rhasspy/
  {
    proxy_pass https://<ip>:<port>/;;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host:$server_port;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
  }

This is strange. somehow I think the Uri is not getting forwarded properly