Nginx 配置反向代理不生效解析

访客 阅读:213 2021-03-31 12:55:01 评论:0

Nginx 配置

 server { 
        listen       8084; 
        server_name  192.168.1.73 localhost; 
		server_name_in_redirect off; 
 
        #charset koi8-r; 
 
        #access_log  logs/host.access.log  main; 
 
		rewrite  ^(.*)(?i)jsessionid(.*)$  /  redirect; 
 
        location / { 
			root   E:/nginx-1.18.0/zrzyj; 
			index  index.html index.htm; 
			try_files $uri $uri/ /index.html; 
        } 
 
        location ~/erms { 
			#Proxy Settings 
 
			add_header Access-Control-Allow-Origin $http_origin; 
			add_header Access-Control-Allow-Headers *; 
			add_header Access-Control-Allow-Methods *; 
 
			proxy_redirect     off; 
			proxy_set_header   Host             $host:$server_port; 
			proxy_set_header   X-Real-IP        $remote_addr; 
			proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for; 
			proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; 
			proxy_max_temp_file_size 0; 
			proxy_connect_timeout      90; 
			proxy_send_timeout         90; 
			proxy_read_timeout         90;			 
			proxy_pass http://192.168.1.73:8815; 
 
        } 
 
        #error_page  404              /404.html; 
 
        # redirect server error pages to the static page /50x.html 
        # 
        error_page   500 502 503 504  /50x.html; 
        location = /50x.html { 
            root   html; 
        } 
 
        
    }

关键点在于设置 server_name_in_redirect off 和proxy_set_header Host $host:$server_port;

声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

发表评论
搜索
排行榜
KIKK导航

KIKK导航

关注我们