0

I can make Nginx respond to www.example.com. But I'd like to redirect www.example.com/site0 to one specific server and www.example.com/site1 to another. It works When I point to the root location www.example.com.

But I can't make Nginx resolve www.example.com/site0 to one specific server

Here is my configuration:

 server {

    listen       80;
    server_name  www.example.com localhost;

    location /site0/ {
       proxy_pass http://0.0.0.0:5000;
       proxy_set_header Host $host;
    }

}

Trying to access www.example.com/site0/ return

192.168.0.254 - - [14/Mar/2018:21:13:28 +0100] "GET /site0 HTTP/1.1" 301 185 "-" "curl/7.54.0"
192.168.0.254 - - [14/Mar/2018:21:13:31 +0100] "GET /site0/ HTTP/1.1" 404 233 "-" "curl/7.54.0"

I don't understand why this is not working. I am using this example in order to configure my server: https://gist.github.com/soheilhy/8b94347ff8336d971ad0

edit :( the error was:

   proxy_pass http://0.0.0.0:5000/;

Note the slash at the end of the target url. I don't know why this is not important for location '/'

Mr Bonjour
  • 121
  • 1
  • 1
  • 4

1 Answers1

0

Quite a big difference between

 proxy_pass http://0.0.0.0:5000;

And

 proxy_pass http://127.0.0.1:5000;
Gerard H. Pille
  • 2,569
  • 1
  • 13
  • 11