0

I have this location element:

location ~* ^/publicapp {
    proxy_pass https://myserver.domain.local;
}

The server myserver.domain.local hosts a web application located under /myapp. I want to make it publicly available via https://www.mywebsite.com/publicapp. How do I tell nginx to translate /myapp to /publicapp? Please keep in mind that I use ~* to allow case-insensitivity. Thus, I cannot use a URI with proxy_pass.

Kind regards, Kevin

bitfrickler
  • 1,193
  • 5
  • 16
  • 26

2 Answers2

0

Try this:

location ~* /publicapp/ {
    rewrite ^/publicapp/(.*)$ /myapp/$1 break;
    proxy_pass https://myserver.domain.local;
}

This will rewrite your path and use new one at the .local server.

pythagor
  • 306
  • 2
  • 5
0

It works using

rewrite ^/publicapp/(.*) /myapp/$1 break;

At least it does with my very simple application. Now I have to figure out how to do proper link translation (sorry for using ISA Server/TMG terms, don't know if it's the same in nginx).

Thanks to pythagor :-)

edit:

Works only if I keep a trailing slash after the url in the browser (https://www.mywebsite.com/publicapp/).

another edit:

To make sure URLs end with a slash:

rewrite ^([^.]*[^/])$ $1/ permanent;

Taken from: here (first answer)

Community
  • 1
  • 1
bitfrickler
  • 1,193
  • 5
  • 16
  • 26