/
nginx.conf
164 lines (124 loc) · 4.52 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
#user nobody;
worker_processes 1;
#worker_cpu_affinity 0010 0100 1000;
#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;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
log_format unicorn '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'upstream_response_time [$upstream_response_time] '
'request_time [$request_time]';
#access_log logs/access.log main;
sendfile on;
tcp_nopush on; # off may be better for *some* Comet/long-poll stuff
tcp_nodelay off; # on may be better for some Comet/long-poll stuff
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip
gzip on;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 500;
gzip_disable "MSIE [1-6]\.";
gzip_types text/plain text/html text/xml text/css
text/comma-separated-values
text/javascript application/x-javascript
application/atom+xml;
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
upstream unifunny{
server unix:/home/funny/funny4.com/current/tmp/sockets/unicorn.socket fail_timeout=0;
}
upstream untianya {
server unix:/home/tianya/tianya.lu/current/tmp/sockets/unicorn.socket;
}
#default server
server {
listen 80;
server_name *.bujiande.com *.panzi.cn *.panzi.com.cn *.twpad.com *.echoff.com;
location / {
root html;
index index.html;
}
error_page 404 500 502 503 504 /index.html;
}
#tianya.lu
server {
listen 80;
server_name tianya.lu *.tianya.lu tianya001.tk *.tianya001.tk tianya002.tk *.tianya002.tk;
client_max_body_size 12m;
access_log /home/tianya/tianya.lu/shared/nginx/access.log unicorn;
error_log /home/tianya/tianya.lu/shared/nginx/error.log;
root /home/tianya/tianya.lu/current/public/;
index index.html;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if ($http_user_agent ~* JoBo ) {
rewrite ^(.*)$ /crawler.html break;
}
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://untianya;
break;
}
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|swf)$ {
access_log off;
expires 180d;
}
}
#funny4
server {
listen 80;
server_name funny4.com *.funny4.com;
client_max_body_size 12m;
access_log /home/funny/funny4.com/shared/nginx/access.log unicorn;
error_log /home/funny/funny4.com/shared/nginx/error.log;
root /home/funny/funny4.com/current/public;
index index.html;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://unifunny;
break;
}
}
location ~ \.(js|css)$ {
gzip_static on;
access_log off;
add_header Cache-Control public;
expires max;
}
location ~* \.(jpg|jpeg|gif|ico|png)$ {
access_log off;
add_header Cache-Control public;
expires max;
}
# redirect server error pages to the stat
error_page 404 /404.html;
error_page 500 502 503 504 /500.html;
}
}