Question

How to Reverse proxy for nginx configuration for subpath in ROOT folder?

I have two servers with different IP addresses:

Nginx is running on port 443, and I’m using it to reverse proxy my webapp this way:

    location /app1/ {
    rewrite ^/app1(.*) /$1 break; 
    proxy_pass https://app1.domain.com/;  }

This way, I normally access my webapp via nginx through https:// nginx.domain.com/app1/.

Secondly, in the ROOT folder of my webapp, I installed the birt-viewer application in the ROOT/birt-viewer folder. I normally access the birt-viewer application when I use the link https:// app1.domain.com/birt-viewer.

However, I don’t normally access the birt application when I use the link https:// nginx.domain.com/app1/birt-viewer. when I copy for example the link /birt-viewer/Task.jsp?__report=Recare.rpgn&sample=my+parameter&__sessionId=2026 and I paste it after the link https:// nginx.domain.com/app1 to obtain the final link https:// nginx.domain.com/app1/birt-viewer/Task.jsp?__report=Recare.rpgn&sample=my+parameter&__sessionId=2026, I access the birt-viewer application but I lose settings such as cookies and sessions.

You understand that to access my webapp via nginx I have to do it manually; the disadvantage is the loss of cookies, sessions and other parameters. Yet access should be done automatically without problems.

This is a part of my nginx config:

 server_name nginx.domain.com; 
    location /app1/ {
     rewrite ^/app1(.*) /$1 break; 
     proxy_pass https:// app1.domain.com/;  }
 
 location /app1/folder1/ {
 rewrite ^/app1/folder1(.*) /$1 break; 
 proxy_pass https:// app1.domain.com/folder1/;  }

I also realize that once my webapp behind nginx, some urls are not up to date and still keep the old access.

So my concern is to access the birt-viewer application automatically (not manually) through nginx via https:// nginx.domain.com/app1/birt-viewer

Does anyone have a solution for me?


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer