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

On Apache you can ProxyPass everything except one or more subdirectories (with "!").

    ProxyPass /subdir !
    ProxyPass / http://localhost:9999/

What is the Nginx equivalent ?

My first guess is obviously not working :

 location /subdir {
      root /var/www/site/subdir;
  }

 location / {
      proxy_pass http://localhost:9999/ ;
  }
share|improve this question

1 Answer 1

You can bind the proxy_pass to EXACTLY the path you like, like this

location = / {
    proxy_pass http://localhost:9999/;
}

This makes sure that no other path will be passed but /

OR

you can use this syntax for just the subdomains to be matched

location ^~ /subdir {
     root /var/www/site/subdir;
}

 location / {
    proxy_pass http://localhost:9999/ ;
}

The ^~ matches the subdir and then stops searching so the / will not be executed. It is described here.

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.