In a word, the address of the Nginx server is actually requested, but the user actually sees the corresponding page of tomcat that we configured, this is the Nginx reverse proxy. Our nginx is the proxy server, and he will distribute our request to the actual server.
Configuring the reverse proxy in the nginx.conf file
In the Nginx directory, enter the command CD conf/
Input Vim ngnix.conf
Configure the following red font to save
Upstreamtomcat_server {
Server 192.168.25.143:8080; Specify the Tomcat_server
}
server {
Listen 80;
server_name localhost;
#charset Koi8-r;
#access_log Logs/host.access.log Main;
Location/{
Proxy_pass Http://tomcat_server; Configure the server that you are acting on
root HTML;
Index index.html index.htm;
}
Test the configuration is successful, start Nginx, directly in the browser to access the address of the Nginx server, if you jump to the configured Tomcat server, the configuration is successful.
Load-balanced configuration, very simple, just need to
Upstreamtomcat_server {
Server 192.168.25.143:8080; Specify the Tomcat_server
Add a Tomcat server address, as follows
Upstream Tomcat_server {
Server 192.168.25.143:8080 weight=20;
Server 192.168.25.144:8080 weight=20; Weight is a weight, and two values are equal to the probability of being distributed by Nginx.
}