V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
paloalto
V2EX  ›  分享发现

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

  •  
  •   paloalto · 2012-03-21 12:58:23 +08:00 · 2696 次点击
    这是一个创建于 4633 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5314 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 08:39 · PVG 16:39 · LAX 00:39 · JFK 03:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.