What is the reverse proxy?
A reverse proxy is a proxy server that accepts a connection request on the Internet and then forwards the request to a server on the internal (or other) network and returns the results obtained from the server to the client on the Internet requesting a connection.
Implementation method:
For example, I would like to build a VPS t.jb51.net domain name used to reverse proxy access to Twitter, first in the domain name registrar where the domain name t.vpser.net add a record to the IP VPS, and then modify the VPS Nginx profile, add the following:
The code is as follows:
Server
{
Listen 80;
server_name t.jb51.net;
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 adding good, first executes:/USR/LOCAL/NGINX/SBIN/NGINX-T check the configuration is normal, if display: the Configuration file/usr/local/nginx/conf/nginx.conf syntax Is OK configuration file/usr/local/nginx/conf/nginx.conf the test is successful normal, otherwise you will be prompted to modify the configuration by error.
Then perform kill-hup ' cat/usr/local/nginx/logs/nginx.pid ' so that the configuration takes effect, and after that, the domain name resolution can be accessed via t.vpser.net.