yohobuypc.conf
2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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;
}
}