Docker Nginx Proxy: how to route traffic to different container using path and not hostname

前端 未结 5 696
北恋
北恋 2021-01-30 05:47

lets say that now I have different app running on the same server on different path:

  • 10.200.200.210/app1
  • 10.200.200.210/app2
5条回答
  •  我在风中等你
    2021-01-30 06:01

    Default bridge network has gateway on 172.17.0.1. You can use this IP address in your nginx.conf

    server {
        listen 80;
        server_name example.com;
    
        location /app1 {
            proxy_pass  http://172.17.0.1:81;
        }
        location /app2 {
            proxy_pass  http://172.17.0.1:82;
        }
    }
    

    They will be accessible using port 80 from outside

    You can check your bridge gateway IP address by running command docker network inspect bridge

提交回复
热议问题