[英]nginx load balancing keep redirect me wrong
hi i have nginx server and other webserver which i want to hide from public direct access. 嗨,我有nginx服务器和其他Web服务器,我想从公共直接访问中隐藏。 but when i try to access that server on root i send redirect response to client to url like this: server/test/spring/main.
但是,当我尝试在根目录上访问该服务器时,我将重定向响应发送给客户端,使其指向如下网址:server / test / spring / main。 when i try to access it from nginx server i get the server url redirect instead nginx url.
当我尝试从Nginx服务器访问它时,我得到服务器URL重定向而不是Nginx URL。
example: 例:
my-nginx.com my-server.com my-nginx.com my-server.com
if i want to access myserver.com/test/spring/main from nginx server i guess i have to access my-nginx.com/test/spring/main but when i do that i get redirect to url myserver.com... 如果我想从Nginx服务器访问myserver.com/test/spring/main,我想我必须访问my-nginx.com/test/spring/main,但是当我这样做时,我会重定向到URL myserver.com ...
my config: 我的配置:
upstream my-server {
server my-server.com;
}
server {
listen 80;
server_name my-nginx;
location / {
proxy_pass http://my-server/;
}
}
the other think is when i access the root page on my-server.com i redirect the client to "https://my-server.com/test/spring/main". 另一个想法是,当我访问my-server.com上的根页面时,我将客户端重定向到“ https://my-server.com/test/spring/main”。
Why i'm redirect from my-nginx.com url to my-server.com? 为什么我从my-nginx.com网址重定向到my-server.com?
This configuration seems do not have big problem, and I also use proxy_pass to access other domain in our production environment, and do not redirect. 此配置似乎没有什么大问题,并且我还使用proxy_pass来访问生产环境中的其他域,并且不进行重定向。
You should be care of the last '/' in " http://my-server/
", usint " http://my-server
" instead, or just using " http://my-server.com
" with no upstream. 您应该注意“
http://my-server/
”中的最后一个“ /”,或者使用usint“ http://my-server
”,或者仅使用“ http://my-server.com
”上游的。
The behavior with '/' or with not '/' is a little different. 使用“ /”或不使用“ /”的行为有些不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.