Home  >  Article  >  Operation and Maintenance  >  How to implement Nginx reverse proxy forwarding tomcat

How to implement Nginx reverse proxy forwarding tomcat

WBOY
WBOYforward
2023-05-17 12:40:251125browse

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;

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
}

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
}

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete