Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 example.com/web. I can not change it. I have everything working except rewriting the url example.com to example.com/web.

I would ideally love to mask the /web part so the user only sees example.com 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;
      server_name example.com;

      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

1 Answer 1

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

Your Answer

 
discard

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.