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

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

    just put this inside /etc/nginx/nginx.conf

        worker_processes  1;
    
        error_log  /var/log/nginx/error.log;
    
        events {
            worker_connections  1024;
        }
    
    
        http {
          server {
                listen 80;
    
                location /api {
                    proxy_pass http://awesome-api;
                    proxy_redirect     off;
                    proxy_set_header   Host $host;
                    proxy_set_header   X-Real-IP $remote_addr;
                    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header   X-Forwarded-Host $server_name;
                }
          }
        }
    
    

提交回复
热议问题