-
Notifications
You must be signed in to change notification settings - Fork 48
/
nginx.conf
272 lines (210 loc) · 7.39 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#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;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
#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.tw";
proxy_set_header Referer https://www.google.com.tw;
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.tw 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;
}
#this can be used to change your index!Just for your convenience!
location =/index.html {
root /var/www/google;
index index.html index.htm;
}
location =/ {
root /var/www/google;
index index.html index.htm;
}
}
#google_proxy config end
#scholar config start
server {
listen 80;
server_name x.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 != "x.adminhost.org" ) {
return 403;
}
access_log off;
error_log on;
error_log /var/log/nginx/scholar-proxy-error.log;
location / {
proxy_redirect off;
proxy_cookie_domain scholar.google.com x.adminhost.org;
proxy_pass https://backend;
proxy_connect_timeout 60s;
proxy_read_timeout 5400s;
proxy_send_timeout 5400s;
proxy_set_header Host "scholar.google.com";
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 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;
}
}
#scholar config end
#add your server in /etc/nginx/vhost like abc.com.conf
include vhost/*.conf;
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}