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

前端 未结 5 645
北恋
北恋 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:18

    Here is a full nginx.conf

    It redirects all to root, and only /api to a different container.

    Source and an example container using it

    user  nginx;
    worker_processes  1;
    
    error_log  /var/log/nginx/error.log;
    
    events {
        worker_connections  1024;
    }
    
    
    http {
      server {
            listen 80;
            location / {
                proxy_pass http://frontend:3000/;
            }
            location /api {
                proxy_pass http://backend/api;
        }
      }
    }
    

提交回复
热议问题