Use Nginx to do reverse proxy under Linux

Source: Internet
Author: User
Tags vps

I. Preparatory work

First of all, you need a stable foreign cheap vps, the old high recommended to the bricklayer, of course you have do such as faster and more expensive VPS on the exception, the Old high blog is built on this VPS.

How to get your VPS, please step 30 yuan a year, build your own rollover wall VPS

Assuming you already have your own VPS, we assume that the CentOS is installed later. So before installing, must execute the command Yum Update-y, lets the system be in the newest state!

Now let's start tossing and going!

II. Download and install Nginx

Of course, use the latest stable version of Nginx, the other version is OK.

Then we start compiling and installing.

Please refer to the installation of the compilation Nginx, note nginx compilation parameters. Where--with-http_spdy_module is Google's spdy, is not very stable, so if you do not need this function, compile the time please delete.

You should be able to access this page once the installation is complete

Welcome to nginx!

Then refer to the Nginx configuration to allow the need to reverse the domain name work, such as binding domain names and so on.

Iii. Configuring the Anti-generation

The simple reverse generation is HTTP, there is no cache control and other advanced functions, just a simple proxy, such as the Old High blog http://www.111cn.net.

In fact, nginx+php is also an inverse generation, as follows:

Location ~ \.php$ {
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}
And the complex point of the reverse generation should be a Google-class HTTPS site, the number of visits may be relatively large, caching and other functions, such as https://www.google.com.

Simple reverse generation

Below the old high domain name Www.111cn.net agent A website For example, describes how to use the reverse generation

Edit the/etc/nginx.conf file, create a new server, and enter the following

server {
Listen 80;
server_name www.111cn.net;

#charset Koi8-r;
#access_log/var/log/nginx/log/www.111cn.net.access.log Main;
Error_log/var/log/nginx/log/www.111cn.net.error.log;
Location/{
Sub_filter t66y.com www.111cn.net; # address Rewrite
Proxy_pass http://t66y.com;
#proxy_redirect off;
#proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
Proxy_set_header Referer http://$host;
}
Error_page 404/404.html;
Error_page 502 503 504/50x.html;
Location =/50x.html {
root/usr/share/nginx/html;
}
}
and restart Nginx.

Service Nginx Restart

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.