Brother Si once reposted an article “How Nginx Reverse Proxy and Replaces URLs”. Although he didn’t steal the content of other people’s sites, the basic process has been realized. Yesterday, someone asked the public service how to use the anti-generation of nginx to realize the thief function according to the tutorial based on the lnmp one-key package of Junge. The public service briefly writes the idea here.
Install some preparatory software
yum -y –noplugins install wget zip
yum -y –noplugins install unzip
yum -y –noplugins install gcc
yum -y –noplugins install make
yum -y –noplugins install pcre-devel
yum -y –noplugins install openssl-devel
yum -y install subversion
Download software
wget -c http://www.nginx.org/download/nginx-1.0.8.tar.gz
wget -c http://wiki.nginx.org/images/5/51/Nginx-accesskey-2.0.3.tar.gz
svn checkout http://substitutions4nginx.googlecode.com/svn/trunk/substitutions4nginx-read-only
compile software
tar -zxf Nginx-accesskey-2.0.3.tar.gz
tar zxf nginx-1.0.8.tar.gz
cd nginx-1.0.8
./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-ipv6 –with-http_gzip_static_module –with-ipv6 — with-pcre –with-http_sub_module –add-module=/root/substitutions4nginx-read-only –add-module=/root/nginx-accesskey-2.0.3
If there are no errors in the compilation, then execute: make but do not make install
After compiling, there is an nginx execution in the objs directory
line file, first back up the original old nginx file, execute: mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old , and then cp the nginx under the new objs to sbin, Execution: cp objs/nginx /usr/local/nginx/sbin/nginx
Execute the /usr/local/nginx/sbin/nginx -t test, it shows that there is no problem
Execute again: make upgrade
Execute: /usr/local/nginx/sbin/nginx -V Look, the module has been compiled.
To add modules to Nginx, you need to execute: killall nginx and then execute: /usr/local/nginx/sbin/nginx cannot use smooth restart.
nginx is under /usr/local/nginx
Configure nginx.conf
server
{
listen 80;
server_name t.ldomain.com; #Bound domain name
root /home/www/html; #Website directory (useful when paired with lnamp!)
access_log off; #off turn off the log
location / {
subs_filter ‘Baidu, you will know’ ‘Four brothers’ gi; #substitutions4nginx replace
(Refer to the official website for usage)
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Referer http://www.baidu.com;
# Mandatory definition of Referer, program verification judgment will be used
proxy_set_header Host www.baidu.com;
#Define the host header, if the domain name bound to the target site matches the server_name item, use $host
proxy_pass http://127.0.0.1; #Specify the target, it is recommended to use IP or nginx custom pool
proxy_set_header Accept-Encoding “”; #clear encoding
}}
or
server_name www.173silk.com;
location / {
subs_filter ca-pub-other gg user ca-pub-replace with yours;
subs_filter 6121088089 612108343455;
//Change the google ad advertising number 6121088089 to your own, you know! 😀
proxy_pass http://kangxiaowei.com; //Reverse this site as an example.
index index.html index.htm;
}
Remember the format of the subs_filter command, it’s up to you if you want to replace it.
In addition, the number of reverse proxies is not limited. As long as you master the rules, a website can contain mirror images of n multiple websites. Multiple n websites can also be run on one nginx. It depends on how you use it.