推荐一份在vps上用nginx做GAE反向代理的nginx.conf配置,涉及到负载均衡、裸域名301转向到www。

2012-03-21 12:58:23 +08:00
 paloalto
user www-data; #有的地方是 www www
worker_processes 1;

#下面两行注意路径,可能有区别,或者不要这两行
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
#注意 mime.types 路径,改为自己的
include /etc/nginx/mime.types;
default_type application/octet-stream;

#access_log /var/log/nginx/access.log;
access_log off;
error_log off;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;

gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";

upstream ghs {
ip_hash;
server ghs.google.com;
server 72.14.203.121;
server 72.14.207.121;
server 74.125.43.121;
server 74.125.47.121;
server 74.125.53.121;
server 74.125.77.121;
server 74.125.93.121;
server 74.125.95.121;
server 74.125.113.121;
server 216.239.32.21;
server 216.239.34.21;
server 216.239.36.21;
server 216.239.38.21;
}

# The ghs.google.com server
server {
listen 80;
server_name www.xibu.biz www.bbttxs.com www.ijd8.com www.yanhuanglian.org;

location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_pass http://ghs;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect false;
access_log off;
error_log off;
}

}

#rewrite
#裸域名301转向到www.*
server {
server_name xibu.biz bbttxs.com ijd8.com yanhuanglian.org;
rewrite ^/(.*) http://www.$host/$1 permanent;
}

#
# The default server
#下面四行作用是:只允许上面的域名绑定,上面没有的或直接输入你VPS IP的可重定向到一个网址
server {
listen 80;
server_name _ 74.63.233.158 *.com *.cn *.org *.mobi *.tel *.asia *.net *.name *.me *.tv *.cc *.hk *.biz *.info;
rewrite ^/(.*) http://www.ijd8.com permanent;
}

#下面两行注意路径,好像不要也行,
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}





via: http://www.xibu.biz/article_399007/%E4%B8%80%E4%BB%BD%E5%AE%8C%E6%95%B4%E7%9A%84nginx%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E9%85%8D%E7%BD%AE
2696 次点击
所在节点    分享发现
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/30204

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX