Preface Today I encountered a very strange problem in nginx. When the front-end tomcat jumped to the page, it jumped to the upstream address and reported 404 directly, but some page accesses were normal. If the access is normal using the intranet ip directly, 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 was found that in the backend Java code, this address was redirected, and request.getServerPort() was used. If it was redirected through nginx, the correct front-end port could not be obtained, and the default return was still 80. If the default listening port of nginx is not 80, 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 nginx configuration file proxy_set_header proxy_set_header Host $host:$proxy_port; The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Implementation of the function of the vue circular percentage progress bar component
>>: Analysis of slow insert cases caused by large transactions in MySQL
When building a database and writing a program, i...
1. What is master-slave replication? Master-slave...
In daily website maintenance and management, a lo...
HTML Input Attributes The value attribute The val...
Table of contents 1. mixin.scss 2. Single file us...
CSS background image flickering bug in IE6 (backg...
http://www.cppcns.com/shujuku/mysql/283231.html Y...
Table of contents Listener 1.watchEffect 2.watch ...
How do I download MySQL from the official website...
OOM stands for "Out Of Memory", which m...
Table of contents Mode Parameters HashHistory Has...
In the following example, when the width of the td...
Building web pages that comply with Web standards ...
Table of contents 1. for loop: basic and simple 2...
my.cnf is the configuration file loaded when MySQ...