Nginx reverse proxy

I am trying to serve Icinga (in a local LAN with ip 10.10.10.7) through a Nginx reverse proxy. The goal is to land on the correct page without having to specify the subfolder /icingaweb2. Here is my conf, which does not work. The commented line works, but it requires specifying the subfolder. What am I doing that is wrong?

server {
        server_name icinga.mydomain.com;
                listen 443 ssl;
                listen [::]:443 ssl;    try_files $uri $uri/ =404;
                auth_basic "Restricted Content";
        auth_basic_user_file /etc/nginx/.htpasswd;
        location / {
            #proxy_pass       http://10.10.10.7;
            proxy_pass       http://10.10.10.7/icingaweb2$request_uri;

        }
 }

Hello @aag1!

Have you tried proxy_pass http://10.10.10.7$request_uri;?

1 Like

I think you want @Al2Klimov 's answer for proxy_pass and then also include a redirect

rewrite ^/$ /icingaweb2/ permanent;

for any direct requests to be forwarded to the icingaweb2 path. You may not want it to be permanent for testing or if you may want the default subfolder to change in the future.

1 Like

dear Lee and AI2Klimov: you are de bestest!!! Thank you so much; your code works exactly as intended!
cheers. AAG

(actually it seems that I don’t even need to add $request_uri, the rewrite rule seems to do the job on its own)