nginx 反向代理時丟失端口的解決方案(轉)

監聽的端口突然在頁面跳轉時丟失了,百度後發現需要如下配置

 server {
        listen       8099;
        server_name  www.abc.com;
		
        charset utf-8;
		autoindex on;
        #access_log  logs/host.access.log  main;

        location / {
		    proxy_set_header X-Forwarded-Host $host;
			proxy_set_header X-Forwarded-Server $host;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header Host $host:$server_port;#一定要加上這句
            proxy_pass http://localhost:9998;
			proxy_redirect  default;
        }
		location /img/ {
			root	static;
			index 3.jpg;
        }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章