求助: 不完全配置如下
server{ 
	listen       80;
	server_name server;
	location / { 
		proxy_pass       http://my.proxy.server; 
		proxy_set_header   Host            $host; 
		proxy_set_header   X-Real-IP        $remote_addr; 
		proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for; 	
	} 
}
server {
   listen  8080;
	server_name 127.0.0.1; 
	index  index.php index.html index.htm;
	root   /www;
	#pathinfo 模式支持
	include vhosts/rewrite/default.conf;
	allow 127.0.0.1;
	deny all;
}
upstream my.proxy.server{
	server 127.0.0.1:8080;
}
问题如下:
一个静态文件,路径是
http://server/a/index,
为什么访问 http://server/a
时跳到
http://server:8080/a/
而我不想把8080端口暴露出来,求教哪里出问题了?
|      1Busy      2016-04-15 14:54:19 +08:00 proxy_pass       http://my.proxy.server:8080; | 
|  |      2lhbc      2016-04-15 15:21:28 +08:00 proxy_redirect http://localhost:8080/ http://$host; | 
|  |      3kookerjp      2016-04-15 15:32:44 +08:00 http { port_in_redirect off; … | 
|      4Jakesoft OP @kookerjp 你这个方法可以,但是我的网站使用了 https,导致 https://server/a 301 到 http://server/a/,然后继续 301 到 https://server/a/,第二个 301 是我自己配置的: rewrite ^(.*)$ https://$host$1 permanent; 关键是第一个 301 是怎么来的,难道反向代理一个静态文件会直接 301 跳转吗? | 
|      5Busy      2016-04-15 16:45:50 +08:00 试试这样 server { listen 80; server_name domain; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:8080; } } 然后给 8080 端口的也写个 server server { listen 8080; server_name 127.0.0.1; location / { root /www; index index.php index.html index.htm; } } 如果不行,则在 8080 的 server 中加 port_in_redirect off; server { listen 8080; server_name 127.0.0.1; port_in_redirect off ; location / { root /www; index index.php index.html index.htm; } } | 
|      6Busy      2016-04-15 16:50:19 +08:00 443 端口应该这样 80 端口跳到 443 ,用 443 端口的 server 去 proxy_pass http://127.0.0.1:8080; |