How can I get nginx to display webapp in *example.com*/here ?

July 29, 2016 406 views
Nginx Server Optimization Ubuntu 16.04

I've built a web app and now I would like to move it to it's own / location on my domain, I thought doing the following would work;

location /here {

but that doesn't work, if I proxy_pass the app to the / location it works fine.

Any help would be greatly appreciated.

1 comment
  • if I proxy_pass the app to the / location it works fine.
    What do you mean? If it works fine, why not do that?
    And just saying "it doesn't work" doesn't say anything. You need logs, configurations, environment information etc. to give some help..

    Try something like this:

            location \here {
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
3 Answers
kamaln7 MOD August 2, 2016
Accepted Answer


If you rewrite the URL before proxying the request to the backend, it will receive the correct URL while still being served under /here:

location /here {
    rewrite ^/here/(.*)$ /$1 break;
    proxy_redirect    off;

What I mean is if a proxy_pass the app at the / location I can view the app fine at my domains address but I dont want that, what I am looking for is have the app be accessible from mydomain.com/HERE.

Have another answer? Share your knowledge.