Home >Backend Development >PHP Tutorial >Problems found during Nginx deployment

Problems found during Nginx deployment

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 09:13:341211browse

1. When developing the SSH project, when nginx configured the service, the action was not configured, and nginx did not forward the action request.

The original is as follows:

#JSP直接给tomcat处理,因为nginx并不是servlet容器,没办法处理JSP
location ~ .*\.(jsp|do)$ {
	proxy_pass    http://mysvr ;
			
	#以下是一些反向代理的配置可删除.
	proxy_redirect    off;

	#后端的<strong>Web服务器</strong>可以通过X-Forwarded-For获取用户真实IP
	proxy_set_header Host $host:9999;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}
is modified as follows:
#JSP直接给tomcat处理,因为nginx并不是servlet容器,没办法处理JSP
location ~ .*\.(jsp|do|action)$ {
	proxy_pass    http://mysvr ;
			
	#以下是一些反向代理的配置可删除.
	proxy_redirect    off;

	#后端的<strong>Web服务器</strong>可以通过X-Forwarded-For获取用户真实IP
	proxy_set_header Host $host:9999;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

2. When nginx is modified not to listen to port 80 (default), if it is modified to port 9999, the port obtained in the background is still port 80. This is nginx The modified port must also be added when setting the real IP and port.

The original is as follows:

#JSP直接给tomcat处理,因为nginx并不是servlet容器,没办法处理JSP
location ~ .*\.(jsp|do|action)$ {
	proxy_pass    http://mysvr ;
			
	#以下是一些反向代理的配置可删除.
	proxy_redirect    off;

	#后端的<strong>Web服务器</strong>可以通过X-Forwarded-For获取用户真实IP
	proxy_set_header Host $host;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}
The modified is as follows:
#JSP直接给tomcat处理,因为nginx并不是servlet容器,没办法处理JSP
location ~ .*\.(jsp|do|action)$ {
	proxy_pass    http://mysvr ;
			
	#以下是一些反向代理的配置可删除.
	proxy_redirect    off;

	#后端的<strong>Web服务器</strong>可以通过X-Forwarded-For获取用户真实IP
	proxy_set_header Host $host:9999;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

The above introduces the problems found during Nginx deployment, including web server aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn