nginx reverse proxy simple example

First, what to do?

Finally, an example implementation of FIG effect:

 

 

 

 

 

 We enter wangtong in the browser address bar, the proxy server gets the request, the request is forwarded on to the designated tomcat

Second, what to do?

1. Prepare the environment

Virtual in the need to install JDK + Tomcat + Nginx, examples I use jdk1.8, Tomcat7 and nginx1.12.2, there is no limit version

2. Configure domain mapping ip address

Open the windows system C: \ Windows \ System32 \ drivers \ etc, open the hosts file

 

 

 In the end of the file add: virtual machine ip address (ip address with your own) wangtong

 

 

 

 

 

 

 3. Configure nginx configuration file

The virtual machine, enter nginx installation address, enter the conf file open nginx.conf

As shown in the figure, nginx open port 80, the server address to your virtual machine ip address,

In the first location is the jump page, add a jump request, proxy_pass http://127.0.0.1:8080, save and exit

So far, this example of configuration even if successful.

4. Test

sbin file into the folder nginx, here is the startup file nginx services

 

 

Restart nginx Service

./nginx -s reload   

Open a browser to access wangtong, you can visit

 

Guess you like

Origin www.cnblogs.com/BeenTogether/p/11607503.html