nginx.test.yohobuy.conf 11.1 KB
server
{
    listen       80;
    server_name  buy.test.yoho.cn *.test.yoho.cn;

    #access_log /Data/logs/access.buy.test.yoho.cn.log  combined;
    error_log  /Data/logs/error.buy.test.yoho.cn.log warn;

    root  /Data/code/git/yohobuy/yohobuy/m.yohobuy.com/public;

    #match ip
    deny 192.168.1.1;
    allow 218.94.75.50;
    allow 218.94.75.58;
    allow 123.56.138.21;
    allow 106.39.86.226;
    allow 172.16.0.0/16;
    deny all;

    #检测是否嵌入APP
    location = /appembed {
        default_type application/json;
        return 200 '{"open":"Y","url":"http://m.yohobuy.com"}';
    }

    #账号相关
    location = /reg.html {
        root  /Data/code/git/yohobuy/assets;
        expires 7d;
    }
    location = /emailback.html {
        root  /Data/code/git/yohobuy/assets;
        expires 7d;
    }
    location = /phoneback.html {
        root  /Data/code/git/yohobuy/assets;
        expires 7d;
    }
    location = /error.html {
        root  /Data/code/git/yohobuy/assets;
        expires 7d;
    }
    location ^~ /passport/back/ {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location ^~ /passport/reg/ {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }

    #首页相关
    location = / {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location = /boys {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location = /girls {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location = /kids {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location = /lifestyle {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location = /girl {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    
    # 商品相关
    location = /cate {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location = /brands {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location = /sale {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location = /brands/search {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location = /product/new {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }

    location ^~ /product/newsale/ {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location ^~ /product/opt/ {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location ^~ /product/recom/ {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }

    # 逛相关
    location ^~ /guang/ {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location ^~ /tags/index {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location ^~ /author/index {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location ^~  /info/index {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location ^~  /info/mini {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location ^~  /plustar {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }

    # 搜索相关
    location ^~ /search {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }
    location ^~ /index/search {
        proxy_redirect off;
        proxy_pass http://yohobuy;
        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   Accept-Encoding "gzip";
    }

    # 热销排行
    location ^~ /hotrank {
        proxy_redirect off;
        proxy_pass http://101.201.176.121;
        proxy_set_header   Host   new.m.yohobuy.com;
        proxy_set_header   X-Real-IP  $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   Accept-Encoding "gzip";
    }

    # 其它访问都跳到老版
    location / {
        proxy_redirect off;
        proxy_pass http://119.254.81.245;
        proxy_set_header   Host   m.yohobuy.com;
        proxy_set_header   X-Real-IP  $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   Accept-Encoding "gzip";
    }

    #location ~* \.html$ {
#        root  /Data/code/git/yohobuy/assets;
#        if (!-f $request_filename){
#            rewrite ^/(.*)$  http://m.yohobuy.com/$1 permanent;
#        }
#        expires  3m;
#    }

    location ~* \.(ico|woff|svg|eot|ttf|otf)$ {
        expires    30d;
    }
    location =/crossdomain.xml {
        expires    30d;
    }
    location =/sitemap.xml {
        expires    1d;
    }
    location =/robots.txt {
        expires    1d;
    }

    #location / {
#        proxy_redirect off;
#        proxy_pass http://yohobuy;
#        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   Accept-Encoding "gzip";
#    }

}

server
{
     listen       80;
     server_name  static.buy.test.yoho.cn;
      
     #access_log /Data/logs/access.static.buy.test.yoho.cn.log  combined;
     #error_log  /Data/logs/error.static.buy.test.yoho.cn.log warn;
      
     root  /Data/code/git/yohobuy/static;

     location / {
         log_not_found off;
         access_log off;
         expires 30d;
     }

     location ~* \.(svg|eot|ttf|woff|otf)$ {
         add_header Access-Control-Allow-Origin *;
         expires 30d;
     }

}

server
{
     listen       80;
     server_name  sale.test.yoho.cn;

     location / {
        proxy_redirect off;
        proxy_pass http://61.155.222.163;
        proxy_set_header   Host   sale.m.yohobuy.com;
        proxy_set_header   X-Real-IP  $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   Accept-Encoding "gzip";
     }
}

server
{
     listen       80;
     server_name  cuxiao.test.yoho.cn;
     location / {
        proxy_redirect off;
        proxy_pass http://101.201.176.121;
        proxy_set_header   Host   cuxiao.m.yohobuy.com;
        proxy_set_header   X-Real-IP  $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   Accept-Encoding "gzip";
     }
}