Home >Operation and Maintenance >Nginx >What is nginx reverse proxy
Reverse proxy: It is used to proxy the server and proxy the target server we want to access.
The proxy server accepts the request, then forwards the request to the server on the internal network (clustered), and returns the results obtained from the server to the client. At this time, the proxy server appears as a server to the outside world.
Nginx provides flexible functions on the reverse proxy. Different forwarding strategies can be used according to different regular rules. After setting up, different requests can be processed. different servers.
The following demonstrates how to configure Nginx to function.
Simulate n http servers as target hosts
For testing, simply use 2 tomcat instances to simulate two http servers, and change the tomcat ports to 8081 and 8082
Configure IP domain name
192.168.72.49 8081
192.168.72.49 8082
Configure nginx.conf
upstream tomcatserver1 { server 192.168.72.49:8081; } upstream tomcatserver2 { server 192.168.72.49:8082; }server { listen 80; server_name 8081.max.com; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://tomcatserver1; index index.html index.htm; } }server { listen 80; server_name 8082.max.com; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://tomcatserver2; index index.html index.htm; } }
Process:
1) Browser access 8081.max.com, through local host file domain name resolution, find the 192.168.72.49 server (install nginx)
2) nginx reverse proxy acceptance The client requests and finds the server node whose server_name is 8081.max.com. According to the http path corresponding to proxy_pass, the request is forwarded to upstream tomcatserver1, that is, the tomcat server with port number 8081.
For more Nginx related technical articles, please visit the Nginx Usage Tutorial column to learn!
The above is the detailed content of What is nginx reverse proxy. For more information, please follow other related articles on the PHP Chinese website!