Nginx没有正确转发url

首先这可能不是问题,但即使如此,我也不知道如何标题这个职位。

我有一个设置redirect每个url的格式xxxx.ops.internal.comauthentication后,相应的URL。

如果我访问URL example.ops.internal.com那么我将被带到example.ops.internal.com但是如果我访问foobar.ops.internal.com我也被带到由example.ops.internal.com提供的内容如果这是有道理的。

看来不pipe我用什么URL, example.ops.internal.com的内容都会返回。

这是configuration:

 server { listen *:8081; server_name example.ops.*; location / { proxy_pass http://hiddenip; proxy_redirect off; } } server { listen *:8081; server_name foobar.ops.*; location / { proxy_pass http://hiddenip2; proxy_redirect off; } } 

似乎总是返回第一台服务器的内容。

这是身份validation发生和redirect发生的方式:

 server { listen *:80; server_name ~^auth.(?<domain>ops.*)$; location = /oauth2/callback { proxy_pass http://google-auth; } location ~/(?<sub>[^/]+)(?<remaining_uri>.*)$ { rewrite ^ https://$sub.$domain$remaining_uri; } } 

也许有些标题没有正确传递?

编辑:

这基本上是我的configurationBitly Oauth2应用程序 ,它显示了port :8081的authentication应用程序。

nginx :80 -> oauth app (using Bitly Oauth2 app) -> nginx :8081 -> requested_route

是简化的应用程序stream程。

Host头没有被正确地转发到oauth应用程序,因此永远不会上游。 main :80服务器上需要此configuration:

 location / { proxy_pass http://google-auth; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; }