我有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
}
}
我有2个容器网站,它们监听app1.com/和app2.com/,它们可以具有相同的端点。我想创建一个Nginx代理来分隔组织:http://
ngx_http_rewrite_module将为您提供帮助