Installation and reverse proxy settings for Nginx

Source: Internet
Author: User

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

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.