-
Notifications
You must be signed in to change notification settings - Fork 1
/
nginx.conf
170 lines (136 loc) · 5.5 KB
/
nginx.conf
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#set upstream
upstream backend {
server 74.125.224.69:443 weight=10;
server 173.194.79.100:443 weight=10;
server 216.58.192.46:443 weight=10;
server 216.58.217.196:443 weight=10;
server 216.58.192.36:443 weight=10;
server 74.125.224.80:443 weight=10;
server 74.125.224.73:443 weight=10;
server 74.125.239.115:443 weight=10;
server 173.194.197.105:443 weight=10;
server 216.58.219.36:443 weight=10;
}
#close server info
server_tokens off;
#set limit of request;open or close it depends on yourself
limit_req_zone $binary_remote_addr zone=setfreq:10m rate=10r/s;
limit_req zone=setfreq burst=20 nodelay;
proxy_cache_path /etc/nginx/cache/one levels=1 keys_zone=one:10m;
proxy_cache_path /etc/nginx/cache/two levels=2:2 keys_zone=two:10m;
proxy_cache_path /etc/nginx/cache/three levels=1:1:2 keys_zone=three:10m;
proxy_cache_valid 200 302 10m;
proxy_cache_valid 301 1h;
proxy_cache_valid any 1m;
client_max_body_size 1024m;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#google_proxy config start
server {
listen 80;
server_name g.adminhost.org;
resolver 8.8.8.8;
#forbid spider
if ($http_user_agent ~* "qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot")
{
return 403;
}
#forbid illegal domain
if ( $host != "g.adminhost.org" ) {
return 403;
}
access_log off;
error_log on;
error_log /var/log/nginx/google-proxy-error.log;
location / {
proxy_redirect off;
proxy_cookie_domain google.com g.adminhost.org;
proxy_pass https://backend;
proxy_connect_timeout 60s;
proxy_read_timeout 5400s;
proxy_send_timeout 5400s;
proxy_set_header Host "www.google.com.hk";
proxy_set_header Referer https://www.google.com.hk;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Accept-Language "zh-CN";
proxy_set_header Cookie "PREF=ID=047808f19f6de346:U=0f62f33dd8549d11:FF=2:LD=en-US:NW=1:TM=1325338577:LM=1332142444:GM=1:SG=2:S=rE0SyJh2W1IQ-Maw";
subs_filter http://www.google.com.hk http://g.adminhost.org;
subs_filter http://www.google.com http://g.adminhost.org;
subs_filter https://www.google.com.tw http://g.adminhost.org;
subs_filter https://www.google.com http://g.adminhost.org;
subs_filter http://scholar.google.com http://x.adminhost.org;
subs_filter https://scholar.google.com http://x.adminhost.org;
#set your analyze code
#subs_filter '</body>' '</body><script src="https://s4.cnzz.com/stat.php?id=1256202926&web_id=1256202926" language="JavaScript"></script>';
sub_filter_once off;
}
}
server {
listen 443;
server_name g.adminhost.org;
ssl on;
ssl_certificate /etc/letsencrypt/live/g.adminhost.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/g.adminhost.org/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
#forbid spider
if ($http_user_agent ~* "qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot")
{
return 403;
}
#forbid illegal domain
if ( $host != "g.adminhost.org" ) {
return 403;
}
access_log off;
error_log on;
error_log /var/log/nginx/google-proxy-error.log;
location / {
proxy_redirect off;
proxy_cookie_domain google.com g.adminhost.org;
proxy_pass https://backend;
proxy_connect_timeout 60s;
proxy_read_timeout 5400s;
proxy_send_timeout 5400s;
proxy_set_header Host "www.google.com.hk";
proxy_set_header Referer https://www.google.com.hk;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Accept-Language "zh-CN";
proxy_set_header Cookie "PREF=ID=047808f19f6de346:U=0f62f33dd8549d11:FF=2:LD=en-US:NW=1:TM=1325338577:LM=1332142444:GM=1:SG=2:S=rE0SyJh2W1IQ-Maw";
subs_filter https://www.google.cn https://g.adminhost.org;
#set your analyze code
#subs_filter '</body>' '</body><script src="https://s4.cnzz.com/stat.php?id=1256202926&web_id=1256202926" language="JavaScript"></script>';
sub_filter_once off;
}
}
#google_proxy config end
}