【发布时间】:2020-06-23 15:44:37
【问题描述】:
我有 2 个容器网站,分别监听 app1.com/ 和 app2.com/,它们可以有相同的端点。
我想为不同的组织创建一个 Nginx 代理:
-
http://<proxy-ip>/organisation1从这里收听app1.com/ -
http://<proxy-ip>/organisation2从这里收听app2.com/
用户应该看到http://<proxy-ip>/organisation1/movies 和所有css/js 被转发到http://<proxy-ip>/organisation1/css/a.css
应用中的位置是app1.com/movies和app1.com/css/a.css等。
问题是重写方法没有转发/organisationX。
如果该位置在实际应用中不存在,如何添加并将其转发到 URL?
server {
listen 80;
location /organisation1 {
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-Proto $scheme;
proxy_set_header X-Forwarded-Host $host/organisation1;
proxy_pass http:app1.com
}
location /organisation2 {
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-Proto $scheme;
proxy_set_header X-Forwarded-Host $host/organisation2;
proxy_pass http:app2.com
}
}
【问题讨论】:
-
所以最终的容器应该这样调用
http://app.com/movies和http://app.com/css/a.css?现在发生了什么?你的问题我不清楚
标签: docker nginx kubernetes nginx-location nginx-reverse-proxy