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

前端 未结 5 692
北恋
北恋 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条回答
  •  旧时难觅i
    2021-01-30 06:14

    Just use nginx image to create container,**do remember set net "host" **which will make your container share same address and port with host machine.mount nginx.conf file and config proxy table.for example:

    docker command:

    docker run --name http-proxy -v /host/nginx.conf:/etc/nginx/nginx.conf --net host -itd --restart always nginx
    

    nginx.conf:

    server {
      listen 80;
      location /app1 {
        proxy_pass YOUR_APP1_URL;
      }
      location /app2 {
        proxy_pass YOUR_APP2_URL;
      }
    }
    

提交回复
热议问题