Simple configuration of Nginx Reverse proxy

Source: Internet
Author: User
Tags nginx reverse proxy

Let's share the following. This method is applicable to the LNMP one-key package of June and the AMH host panel (of course, AMH comes with the anti-generation module.
The following is a simple reverse proxy configuration:

Server
        {
Listen 80;
Server_name 111cn.net www.111cn.net;
Location /{
Proxy_pass http://www.baidu.com;
Proxy_redirect off;
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
    }
}
Field explanation:
Server_name: your own domain name
Proxy_pass: the domain name to be reversed. The Baidu address entered here is used to request Baidu content and return it to the client when accessing www.111cn.net.
Save the above code as "your domain name. conf ", such as 111cn.net. conf, then place the configuration file to "/usr/local/nginx/conf/vhost" on the server, and then restart the nginx service. LNMP 1.2 enter the command "lnmp nginx restart ", AMH 4.2 enter the command "amh nginx restart" to restart and take effect.
Finally, resolve your domain name to the server where it is located for access. The above rules only implement the most basic reverse proxy. In addition, you can use nginx rules to implement keyword replacement and cache directories, if you are interested, you can find more information about nginx on the Internet.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.