由于手里的域名太多没用,老是想怎么给他利用起来。后来想到可以反向代理一些其他有用的网站,做个说明方便以后常使用:
首先是安装nginx,我一直是使用的军哥的lnmp 里边自带nginx,自己在网站搜LNMP里边就有怎么安装,这里就不阐述了,
# 下面这段代码才是 HTTP 完整示例配置文件,注意使用时修改里面的默认域名等信息。
server
{
listen 80;
server\_name www.vjsun.com;
if ($http\_user\_agent ~* (baiduspider|360spider|haosouspider|googlebot|soso|bing|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot|MJ12bot|NHN|Twiceler)) {
return 403;
} #第二段是 屏蔽搜索引擎收录,比如镜像自己的网站,如果不屏蔽会导致 收录流失。
location / {
sub\_filter www.google.com www.vjsun.com;
sub\_filter\_once off;
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.google.com;
proxy\_set\_header Host www.google.com;
proxy\_pass http://www.google.com;
proxy\_set\_header Accept-Encoding "";
}
}
说明解释:
server\_name 你的域名;
sub\_filter 欲被镜像的域名 你的域名;
proxy\_set\_header Referer http://欲被镜像的域名;
proxy\_set\_header Host 欲被镜像的域名;
proxy\_pass http://欲被镜像的域名;
# 下面这段代码才是 HTTPS 完整示例配置文件,注意使用时修改里面的默认域名等信息。
server
{
listen 80;
listen 443 ssl;
ssl on;
ssl\_certificate /root/ssl.crt;
ssl\_certificate\_key /root/ssl.key;
ssl\_session\_cache shared:SSL:10m;
ssl\_session\_timeout 10m;
server\_name www.vjsun.com;
add\_header Strict-Transport-Security "max-age=31536000";
if ( $scheme = http ){
return 301 https://$server\_name$request\_uri;
}
if ($http\_user\_agent ~* (baiduspider|360spider|haosouspider|googlebot|soso|bing|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot|MJ12bot|NHN|Twiceler)) {
return 403;
}#第三段是 屏蔽搜索引擎收录,比如镜像自己的网站,如果不屏蔽会导致 收录流失。
location / {
sub\_filter www.google.com www.vjsun.com;
sub\_filter\_once off;
proxy\_set\_header X-Real-IP $remote\_addr;
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;
proxy\_set\_header Referer https://www.google.com;
proxy\_set\_header Host www.google.com;
proxy\_pass https://www.google.com;
proxy\_set\_header Accept-Encoding "";
}
}