Skip to content Skip to sidebar Skip to footer

How To Use Custom Location Or Path Instead Root For Several Apps Using Nginx?

Problem I have a web which works fine on a root domain like mydomain.com without any modification. But if I want to serve it as mydomain.com/app1 I I need to modify the source code

Solution 1:

Should you always modify the application when you want to assign a domain/path?

No, you shouldn't have to modify the application at all.

When you use proxy_pass in this manner, you need to rewrite the URL with regex. Try something like this:

  location ~ ^/app1/(.*)$ { 
    proxy_pass http://localhost:8080/$1$is_args$args; 
  }

See also: https://serverfault.com/q/562756/52951

Post a Comment for "How To Use Custom Location Or Path Instead Root For Several Apps Using Nginx?"