Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having some trouble making a url while I pass the request off to an upstream server.

Basically, the webapp on an upstream server that I am trying to setup has to exist at the location I can not change it. I have everything working except rewriting the url to

I would ideally love to mask the /web part so the user only sees but I will be happy with at least getting Nginx to automatically add the /web for the user. Currently I have to manually add /web to the url to get to the app.

My current config is:

  upstream app {
      server x.x.x.x:port;

  server {
      listen 80;

      location / {
          try_files $uri @backend;

      location @backend {
          proxy_pass http://app;
          proxy_set_header Host $host;

Any help is greatly appreciated.

share|improve this question
up vote 0 down vote accepted

You should take a look at the official documentation for the http_rewrite_module of NGINX.

There are lots of example doing what you're trying to achieve.

share|improve this answer
URI masking is different from rewriting url. – iankit Nov 18 '15 at 12:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.