Original: Curly brace MC(wechat official account: Huakuohao-MC), welcome to share, please keep the source.
Regarding Nginx, in addition to using it as a normal Web server, it is often used as a network proxy server; To solve the problem of limited network access. The most commonly discussed topics are “forward proxies” and “reverse proxies”. Many people often fail to understand what is a “forward proxy” and what is a “reverse proxy”. What is the difference between them?
Nginx has only one proxy forwarding feature. The reason people often say forward proxy or reverse proxy is because they stand at different angles. We can imagine the 80-90’s, the old man in charge of sending and receiving letters in the agency compound, the old man sending and receiving letters action, imagine Nginx to request forwarding function.
We define it as a forward proxy when the old man sends an internal letter to the outside, and it is called a reverse proxy when the old man forwards an external letter to the inside to every specific person inside. But for the old man is the agent, the completed action is the same. The same is true for Nginx, where all network request forwarding instructions are the same.
Nginx proxy instruction comparison
- Forwarding internal requests to the external.
upstream baidu { server www.baidu.com; } server{ listen 8100; server_name proxy_baidu; location / { proxy_pass http://baidu; }}Copy the code
Accessing proxy_IP :8100 will send the request through a proxy server.
- Forward external requests internally
upstream test-api { ip_hash; Server 192.168.32.12:80; Server 192.168.32.13:80; } server{ listen 8080; location / { proxy_pass http://test-api; }}Copy the code
This configuration will forward external requests to Nginx to internal servers 192.168.32.12 and 192.168.32.13.
conclusion
By comparing the two configurations, you can see that the instructions are the same to Nginx for both forward and reverse proxies. So for Nginx, it’s all proxies, no matter what. Finally, a diagram is attached to further illustrate the role of the Nginx network agent.
Recommended reading
1. Java concurrent programming stuff (10) — Final summary
2. How to understand the Class Class in Java
3. Do you know how to use Awk
4. Teach you how to build a set of ELK log search operation and maintenance platform
Original: Curly brace MC(wechat official account: Huakuohao-MC) Focus on JAVA basic programming and big data, focus on experience sharing and personal growth.