In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how nginx does not jump to upstream address, has certain reference value, interested friends can refer to, I hope you have a lot of gains after reading this article, let Xiaobian take you to understand.
preface
In nginx encountered a very strange problem, in the front tomcat jump page when the jump is upstream address, directly reported 404, but some page access is normal.
http://tomcat/tomcat-web/account/index
If it is normal to directly access the intranet ip, it can be determined that it is a problem with nginx. The nginx configuration is as follows
upstream tomcat { server 192.168.11.172:8061; server 192.168.11.172:8062; ip_hash; } server { listen 8060; server_name www.example.com; location / { proxy_pass http://tomcat; proxy_set_header Host $host:8060; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; index index.html index.htm; } }
After investigation, it is found that because in the backend java code, this address is redirected, which uses request.getServerPort(). If it is through nginx, the correct port of the front end cannot be obtained. The default return is still 80. If the port of nginx listening is not 80 by default, response.sendRedirect cannot jump to the correct address.
response.sendRedirect(getBasePath(request) + "account/index"); private String getBasePath(HttpServletRequest request) { String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; return basePath; }
The solution is to add the port number to the proxy_set_header of the nginx configuration file
proxy_set_header Host $host:$proxy_port; Thank you for reading this article carefully, I hope Xiaobian shared "nginx did not jump to the upstream address how to do" This article is helpful to everyone, but also hope that everyone a lot of support, pay attention to the industry information channel, more relevant knowledge waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.