这是问题所在:
主机上有多个Docker应用程序在不同的端口上运行,例如App1 @ 3001,App2 @ 3002...3100等。
现在我想以此格式访问这些应用:http://hostname.com/app1、http://hostname.com/app2...
为了实现这一点,我在主机上运行nginx来代理请求到正确的端口,基于子URI。
但是当网站的子URI更改或网站重定向时,这种方法并不起作用。例如:
主机上有多个Docker应用程序在不同的端口上运行,例如App1 @ 3001,App2 @ 3002...3100等。
现在我想以此格式访问这些应用:http://hostname.com/app1、http://hostname.com/app2...
为了实现这一点,我在主机上运行nginx来代理请求到正确的端口,基于子URI。
location = /app1 {
proxy_redirect http://hostname:3001/;
include /etc/nginx/proxy_params;
}
location ^~ /app1 {
proxy_redirect http://hostname:3001/app1;
include /etc/nginx/proxy_params;
}
但是当网站的子URI更改或网站重定向时,这种方法并不起作用。例如:
If I visit the site at hostname:3001 -> I can see the site
If I visit the site at http://hostname.com/app1 -> I can see the site
If the site page is at hostname:3001/static/index.html then when i access it as http://hostname.com/app1 the page changes to http://hostname.com/static/index.html -> I get 404.
有没有其他方法可以实现这个目标?或者唯一的方法是将DNS设置为app1.hostname.com并进行基于名称的路由?