Because of the project, contact the Nginx installation and reverse proxy settings, and share it with you.
One. Nginx Download, installation
Cd/home
wget http://nginx.org/download/nginx-1.0.5.tar.gz
TAR-ZXVF nginx-1.0.5.tar.gz
CD nginx-1.0.5
./configure
Make
Make install
Two. Reverse proxy settings
Edit the Nginx configuration file vi/usr/local/nginx/conf/nginx.conf, replacing the contents of {} in server {} as follows:
server {
Listen 80;
server_name nginx.urbansh.com;
#charset Koi8-r;
#access_log Logs/host.access.log Main;
Location/{
Proxy_pass http://www.urbansh.com;
Proxy_redirect off;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
}
}
A simple explanation of the above code: server_name Specifies the name of the reverse proxy server, either IP or the domain name that resolves to the reverse proxy server IP (that is, configuring multiple virtual hosts to implement the reverse proxy). Proxy_pass http://www.urbansh.com; Specifies the Web site to which the proxy server wants to reverse proxy. This example can be implemented when accessing nginx.urbansh.com (nginx.urbansh.com resolves to the reverse proxy server IP, does not need to really configure this virtual host), will access to the content of the www.urbansh.com site.
Note: After the nginx.conf configuration file has changed, you need to restart Nginx to take effect, by:
Ps-ef | grep nginx
See similar to the following:
After:
Kill-hup 3497
You can restart the Nginx server.
Each time you make a change to the configuration file, you can/usr/local/sbin/nginx-t this method to check if there is a problem with the change, and if there is no syntax error, you will be prompted:
Installation and reverse proxy settings for Nginx