Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Nginx to implement reverse proxy

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge about "how to use Nginx to implement reverse proxy". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

What is a proxy server?

Proxy server: When the client sends a request, it is not directly sent to the destination host, but first sent to the proxy server. After receiving the client request, the proxy service sends it to the host, receives the data returned by the destination host, stores it in the hard disk of the proxy server, and then sends it to the client.

Role of proxy server

Improve access speed (popular website must be equipped): usually proxy servers are set up a larger buffer, when there is external information through, but also save it to the buffer, when other users access the same information, then directly from the buffer to take out the information, to the user to improve access speed.

Hidden real identity (website security enhancement): Internet users can also hide their real address information through proxy servers, and can also hide their IP to prevent hackers from attacking.

Breaking through restrictions (surfing the web): Sometimes Internet providers impose restrictions on Internet users 'ports, destination sites, protocols, games, instant messaging software, etc. These restrictions can be broken using proxy servers.

Forward and reverse proxies

Positive agent, such as you want to buy a house, but your funds are not enough, so you go to Wang Sicong to borrow money, must be rejected; at this time you find out that one of your good friends Xiao A and Wang Sicong are classmates, so you ask Xiao A to help you borrow money from Wang Sicong, borrow money successfully. Small A in this process is agent, accurate point is positive agent, small A borrowed money for you, this process, very critical is who the real borrower is, Wang Sicong is not known.

We often say that the proxy also refers to the positive proxy, the process of positive proxy, it hides the real request client, the server does not know who the real client is, the service requested by the client is replaced by the proxy server to request, for example, the scientific Internet tool Shadowsocks plays a typical positive proxy role.

Reverse proxy, such as you dial 10086, a region of 10086 customer service hundreds of thousands, you do not need to care about which one at the end of the phone, you care about your problem can not get professional answers; then here 10086 switchboard number is what we say reverse proxy. Customers don't know who is actually providing the service.

Reverse proxy hides the real server, when we visit www.baidu.com, there may be thousands of servers behind us, but you don't know which one, www.baidu.com is our reverse proxy server, reverse proxy server will help us forward the request to the server that provides real computing.

The difference between the two is that the object of the proxy is different, the object of the "forward proxy" proxy is the client, and the object of the "reverse proxy" proxy is the server.

Reverse Proxy Application Scenarios

Many large Web sites use reverse proxies today. Used to prevent malicious attacks on intranet servers from external networks; cache to reduce server pressure and access security control; and achieve Load Balancer.

Practice Configuring Reverse Proxy Server Nginx

Nginx as the most popular reverse proxy server, the following example uses nginx reverse proxy, multi-domain site configuration:

Configure IP Domain Names

172.16.100.108 www.a.com

172.16.100.108 www.b.com

upstream www_a_com { server 172.16.100.108:8001; } upstream www_b_com { server 172.16.100.108:8002; } server { listen 80; server_name www.a.com; charset utf-8; autoindex off; location / { proxy_pass http://www_a_com; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 80; server_name www.b.com; charset utf-8; autoindex off; location / { proxy_pass http://www_b_com; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } The content of "How to use Nginx to implement reverse proxy" is introduced here. Thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report