question After Nginx reverse proxy, the Tomcat application obtains the Nginx host through For example, on a certain server, Tomcat's port number is 8080, Nginx's port number is 80, and Nginx reverse proxy is port 8080. server { listen 80; location / { proxy_pass http://127.0.0.1:8080; } } On another machine, use a browser to open System.out.println(request.getHeader("host")); turn out:
Causes of the problem Nginx's reverse proxy is actually a bridge between the client and the real application server. The client (usually a browser) accesses the Nginx server, and Nginx then accesses the Web application server. For the Web application, the client of this HTTP request is Nginx rather than the real client browser. If no special processing is done, the Web application will regard Nginx as the request client, and the client information obtained is some information about Nginx. Problem Solving Nginx configures HTTP Header. Host contains the client's real domain name and port number proxy_set_header Host $http_host; Tomcat obtains client information from the HTTP Header passed by Nginx. <Valve className="org.apache.catalina.valves.RemoteIpValve" /> Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
>>: How to bypass unknown field names in MySQL
Table of contents 1. What is a trigger? 2. Create...
Before using idea to write JSP files, you need to...
Preface First, let me introduce Keepalived, which...
Use navicat to test and learn: First use set auto...
When insert into employee values(null,'張三'...
answer from stackflow: Simply <br> is suffic...
Mixins provide a very flexible way to distribute ...
Table of contents The dynamic particle effects ar...
Table of contents event Page Loading Event Delega...
Preface Recently, a Java EE web project that has ...
I recently joined a new company and found some mi...
Preface In the early stages of some projects, dev...
Table of contents 1. Realistic Background 2. Agre...
Let's first look at several ways to submit a ...
This article example shares the specific code of ...