yohobuypc.conf 2.26 KB
server
{
    listen       80;
    server_name  www.yohobuy.com *.yohobuy.com www.yhbimg.com;
    root  /Data/PE/yohobuy_pc/yohobuy/www.yohobuy.com/public;

    access_log /Data/logs/nginx/access_pc.yohobuy.com.log  fenxi;
    error_log  /Data/logs/nginx/error_pc.yohobuy.com.log warn;

    ######force https to http ######
    
    set $rewite 0;
    if ($http_x_client_proto = 'http') {
        set $rewite 1;
    }
    if ($http_x_forwarded_proto = 'http') {
        set $rewite 1;
    }
    
    # is windows xp
    if ($http_user_agent ~* "NT 5.[0-9]+") {
        set $rewite 0;
     }
    
    if ($rewite = 1) {
        return 301  https://$host$request_uri ;
    }

	# nginx status check
    location = /status_check {
           default_type text/html;
           return 200  'server is ok!';  
    }
        
    location / {
        if ($http_user_agent ~* "Scrapy") {
            return  403;
        }
        if ($http_user_agent ~ ^$) {
            return 403;
        }
        set $self_remote_addr $http_x_forwarded_for;
        include vhosts/pc/cache.conf;
        # proxy_ignore_headers "Set-Cookie"; # 绝对不能加,加了存在串 sessionID 的隐患
        #req_limit
        limit_req zone=allips_per_ip_50 burst=20 nodelay;
        include vhosts/pc/node-proxy.conf;
   }

   location ~ \.html$ {
      
        if ($http_user_agent ~* "Scrapy") {
            return  403;
        }
        if ($http_user_agent ~ ^$) {
            return 403;
        }
        set $self_remote_addr $http_x_forwarded_for;
        include vhosts/pc/cache.conf;
        limit_req zone=allips_per_ip_50 burst=20 nodelay;
        include vhosts/pc/node-proxy.conf;
   }

   location = /favicon.ico {
       expires    30d;
   }

   location = /crossdomain.xml {
       expires    30d;
   }

 
 
 
   location ^~ /chanpin/ {
        set $self_remote_addr $http_x_forwarded_for;
        include vhosts/pc/cache.conf;
        proxy_ignore_headers "Cache-Control" "Expires" "Vary";
        include vhosts/pc/node-proxy.conf;
   }

}

server
{
    listen       80;
    server_name  yohobuy.com;
    
    location / {
        return 301 http://www.yohobuy.com$request_uri;
    }
}

server
{
   listen       80;
   server_name  api.open.yohobuy.com service.api.yohobuy.com;
   location / {
      return 404;
   }
}