2017-05-25 36 views

回答

0

您可以配置兩個上游並重定向從/ a到第一個,從/ b到第二個。事情是這樣的:

upstream first { 
     server 172.17.0.4:5000; 
     server 172.17.0.3:5000; 
    } 

    upstream second { 
     server 172.17.0.5:5000; 
    } 

    server { 
    ... 

     location /a { 
      proxy_pass http://first; 
      include /etc/nginx/proxy_params; 
     } 

     location /b { 
      proxy_pass http://second; 
      include /etc/nginx/proxy_params; 
     } 
    } 
+0

ok了,怎麼樣下列選項: - 當請求到達網址:www.example.com - >將被引導到容器中的 - 當請求到達URL:www.example.com/something - >它將被引導到容器B 使用變量如VIRTUAL_HOST,VIRTUAL_PORT我​​無法區分這一點。 – ivo

+0

非常相似:您必須使用塊「位置/」指向容器A,「位置/某處」指向容器B – AlexErofeev