When it comes to how to configure Nginx Reverse proxy First, let's understand what is reverse proxy. Reverse proxy is a proxy server that accepts Internet connection requests, and then forwards the requests to another server.
Originally, I could not use the reverse proxy for a long time, so I never did. It happened that a space on EWSIDC a few days ago was not allowed to be bound because of the problem of the domain name (imzhaorong. com) BA, and could only be accessed through the three-level domain name provided by the system. But I still want to use the original top-level domain name to access the content of this space. What should I do? Use the VPS in hand to do reverse proxy. Next, let's look at the detailed process.
First, let's talk about the general environment. The non BA top-level domain name I use is imzhaorong.com, the EWSIDC level 3 domain name is 1e01f.wi.ipc.la, and the VPS I use is the $1 cloud VPS of Host1Plus, and LNMP has been installed.
First, we need to record the domain name imzhaorong.com resolution A to the VPS IP address;
Then, modify nginx Configuration file. In this tutorial, we will download the nginx. conf of VPS to local modification (the file directory is located in/usr/local/nginx/conf/). Let me start with the last screenshot:
The blue part in the figure is the code we added. The reason why we need to add a picture is to pay attention to the location of the code. Zhao Rong had made a mistake before. Fortunately, the fourth senior brother mentioned something. Now, I will paste the code:
server {
listen 80;
server_name imzhaorong.com;
location / {
proxy_pass http://1e01f.wi.ipc.la/ ;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
After the modification, we first execute:/usr/local/nginx/sbin/nginx - t to check whether the configuration is normal. If the configuration file/usr/local/nginx/conf/nginx. conf syntax is ok configuration file/usr/local/nginx/conf/nginx. conf test is successful, it is normal. Otherwise, if the configuration is modified according to the error prompt, the error prompt will be accurate to which line.
Finally, execute kill HUP ` cat/usr/local/nginx/logs/nginx. pid ` to make the configuration take effect. If your domain name resolution also takes effect, you should be able to access it directly through the top-level domain name.
There are many uses of reverse proxy. Let's explore them by ourselves.
Statement: Blogs are only for sharing information and are not recommendations. Websites do not participate in transactions and are not intermediaries. The content only represents personal views and is not authoritative. Readers should consider it and take their own risks! Every penny and every commodity is still the eternal truth. Juvenile readers (including physical and psychological) should visit this website with their guardians! This article is written by( Zhao Rong )Original compilation, reprint, please keep the link: Nginx (LNMP) Reverse Proxy Configuration Tutorial The code is not easy, please do not copy or paste! About using: This website mainly shares server and VPS information, and does not provide any product sales or purchase. All visitors please purchase and use products within the scope of national laws and regulations. QQ group discussion: 683851361 About safety: Any IDC has the possibility of going bankrupt and running away. The host line is even more uncontrollable. Monthly payment and backup are your best choices. Please keep good and regular backup habits