How to implement Nginx reverse proxy forwarding tomcat

WBOY
Release: 2023-05-17 12:40:25
forward
1124 people have browsed it

Let’s talk about the forward proxy first. For example, if you want to access YouTube, but you cannot access it directly, you can only find a circumvention software first, and you can access YouTube through the circumvention software. The circumvention software is called a forward proxy.

The so-called reverse proxy means that the user wants to access YouTube, but YouTube quietly hands the request to bilibili, then bilibili is a reverse proxy.

In the current tutorial, it refers to accessing nginx, but nginx hands the request to tomcat.

Not much to say, you can access the corresponding interface up to ports 80 and 8080. Of course, you can also set the port yourself

Configure nginx.conf in the conf folder under Nginx

vim nginx.conf

The picture below is the original configuration

How to implement Nginx reverse proxy forwarding tomcat

Compared to the newly downloaded nginx original There are two configuration changes

The first one:

server_name localhost;
Copy after login

is changed to server_name tomcat’s access IP and port;

For example, mine is server_name 192.168.19.130:8080;
(Self-modified)

Second place:

location /{<!--{cke_protected}{C}%3C!%2D%2D%20%2D%2D%3E-->
root html;
index index.html index.htm
}
Copy after login

is changed to:

location /{<!--{cke_protected}{C}%3C!%2D%2D%20%2D%2D%3E-->
root html;
index index.html index.htm
proxy_pass http://192.168.19.130:8080
}
Copy after login

When only one server is configured, server_name is optional and the system does not The configuration will be loaded. When there are multiple servers, server_name must be configured, and the nginx service will match according to this configuration.
(ps: This is the best configuration. Personally, it took me a long time to implement the reverse proxy because I didn’t configure it)

Here you can enter nginx -s under the sbin folder Reload and restart nginx

Access 192.168.19.130:80

How to implement Nginx reverse proxy forwarding tomcat

The whole process is done on the virtual machine

The above is the detailed content of How to implement Nginx reverse proxy forwarding tomcat. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!