Configure Nginx Reverse proxy on LinuxVPS

Source: Internet
Author: User
Tags nginx reverse proxy
Nginx is a high-performance HTTP and reverse proxy server. Deepvps has previously introduced Nginx HTTP applications many times, such as the one-click installation package of lnmp. The following describes the reverse proxy function of Nginx. What is reverse proxy? A reverse proxy is used to receive connection requests from the Internet by the proxy server, and then forward the requests.

Nginx is a high-performance HTTP and reverse proxy server. Deepvps has previously introduced Nginx HTTP applications many times, such as the one-click installation package of lnmp. The following describes the reverse proxy function of Nginx.

What is reverse proxy?

A reverse proxy is a proxy server that accepts connection requests from the Internet and forwards the requests to an internal (or other) network server, return the result obtained from the server to the client requesting connection from the Internet.


Implementation method:

For example, if I want to create A domain name www.linuxidc.com on Linux VPS for reverse proxy access to twitter, I first add A record to the VPS IP address for the domain name www.linuxidc.net on the domain name management at the domain name registrar, modify the Nginx configuration file on VPS and add the following:

Server
{
Listen 80;
Server_name www.linuxidc.com;

Location /{
Proxy_pass http://twitter.com /;
Proxy_redirect off;
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
}
} After the configuration is added, run:/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. otherwise, modify the configuration according to the error message.

Run kill-HUP 'cat/usr/local/nginx/logs/nginx. pid 'to make the configuration take effect. after domain name resolution takes effect, you can access twitter through www.linuxidc.net.
 

 

Related Article

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.