When it comes to how to configure NginxReverse proxyFirst, 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, modifynginxConfiguration 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:
After modification, we first execute:/usr/local/nginx/sbin/nginx - t to check whether the configuration is normal. If it displays:the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok configuration file /usr/local/nginx/conf/nginx.conf test is successful Otherwise, modify the configuration according to the error prompt, and 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.