通过在URL上添加/ organizationx路径来分隔具有相同域名的网站

问题描述 投票:0回答:1

我有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/moviesapp1.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:// / ...

docker nginx kubernetes nginx-location nginx-reverse-proxy
1个回答
0
投票

ngx_http_rewrite_module将为您提供帮助

© www.soinside.com 2019 - 2024. All rights reserved.