nginx 監聽非標准端口80,重定向端口丟失問題解決


使用nginx監聽8070端口,並轉發到8067端口

我的配置文件如下:

upstream odoo {
	server localhost:8067;
}
upstream odoochat{
	server localhost:8072;
}
server {
	listen 8070 default_server;
	listen [::]:8070 default_server;

	root /var/www/html;
	index index.html index.htm index.nginx-debian.html;

	server_name _;


	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		# try_files $uri $uri/ =404;
	        # proxy_redirect off;
		 proxy_pass http://odoo;
		# index index.html;
        proxy_set_header Host $host;  
        proxy_set_header X-Real-IP $remote_addr;  
        proxy_set_header X-Forwarded-HOST $host:$server_port;  # 關鍵需要在此處添加端口號變量,或者直接使用端口號8070
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}
	location /longpolling{
		proxy_pass http://odoochat;
	}

ps:我是用來反向代理odoo系統,測試結果是ok的


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM