-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
196 lines (166 loc) · 4.78 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
#user nginx;
user www-data;
pid /run/nginx.pid;
worker_processes 2;
worker_rlimit_nofile 12288;
events {
worker_connections 4096;
}
http {
log_format ltsv "status:$status"
"\ttime:$time_iso8601"
"\treqtime:$request_time"
"\tmethod:$request_method"
"\turi:$request_uri"
"\tprotocol:$server_protocol"
"\tua:$http_user_agent"
"\tforwardedfor:$http_x_forwarded_for"
"\thost:$remote_addr"
"\treferer:$http_referer"
"\tserver_name:$server_name"
"\tvhost:$host"
"\tsize:$body_bytes_sent"
"\treqsize:$request_length"
"\truntime:$upstream_http_x_runtime"
"\tapptime:$upstream_response_time"
"\tuid:$upstream_http_x_isu_userid"
"\txtime:$upstream_http_x_isu_time"
"\treqid:$upstream_http_x_isu_reqid";
#access_log /var/log/nginx/access.log ltsv;
access_log off;
error_log /var/log/nginx/error.log warn;
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
open_file_cache max=1024 inactive=60s;
tcp_nopush on;
#gzip on;
#gzip_min_length 1100;
#gzip_buffers 4 8k;
#gzip_types application/atom+xml text/plain text/css text/javascript application/json application/javascript;
#gzip_vary on;
#gzip_disable "MSIE [1-6]\.";
gzip_static on;
keepalive_timeout 65;
# keepalive_requests 10000;
proxy_buffers 100 32k;
proxy_buffer_size 8k;
client_body_buffer_size 2M;
client_max_body_size 20M;
upstream app {
server unix:/run/isupipe/puma.sock fail_timeout=0;
#server 127.0.0.1:8080 fail_timeout=0;
}
upstream isu1 {
#server isu1:8888 fail_timeout=0;
server unix:/run/isupipe/puma.sock fail_timeout=0;
}
upstream isu3 {
server isu3:8888 fail_timeout=0;
}
upstream isu {
#server isu1:8888 fail_timeout=0;
server unix:/run/isupipe/puma.sock fail_timeout=0 weight=16;
server isu2:8888 fail_timeout=0 weight=20;
server isu3:8888 fail_timeout=0 weight=2;
}
server {
listen 8888;
listen [::]:8888;
access_log off;
location / {
proxy_set_header Host $host;
proxy_read_timeout 600;
proxy_ignore_headers X-Accel-Redirect;
add_header "X-Accel-Redirect" $upstream_http_x_zoo_redirect;
proxy_pass http://app;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name u.isucon.dev;
server_name *.u.isucon.dev;
ssl_certificate /etc/nginx/tls/_.u.isucon.dev.crt;
ssl_certificate_key /etc/nginx/tls/_.u.isucon.dev.key;
ssl_protocols TLSv1.3;
ssl_prefer_server_ciphers off;
client_max_body_size 10m;
root /home/isucon/webapp/public/;
location / {
try_files $uri /index.html;
}
location /api {
proxy_set_header Host $host;
proxy_read_timeout 600;
proxy_pass http://isu;
}
location = /api/initialize {
proxy_set_header Host $host;
proxy_read_timeout 600;
proxy_pass http://isu1;
}
location = /api/icon {
proxy_set_header Host $host;
proxy_read_timeout 600;
proxy_pass http://isu1;
}
location = /api/register {
proxy_set_header Host $host;
proxy_read_timeout 600;
proxy_pass http://isu1;
}
#location = /api/livestream/reservation {
# proxy_set_header Host $host;
# proxy_read_timeout 600;
# proxy_pass http://isu3;
#}
location ~ ^/api/user/(?<requsername>[^/]+)/icon$ {
root /home/isucon/webapp;
types { }
default_type image/jpeg;
etag off;
add_header x-username "u-$requsername";
try_files /files/$requsername /default/icons/$requsername =404;
if ($http_if_none_match) {
rewrite ^.+$ /api/shirokanezoo/usericon/$requsername;
}
}
location /api/shirokanezoo/usericon {
proxy_set_header Host $host;
proxy_read_timeout 600;
proxy_pass http://isu;
}
location ~ ^/api/shirokanezoo/usericon2/(?<requsername>.+)$ {
root /home/isucon/webapp;
types { }
default_type image/jpeg;
etag off;
add_header x-username "u-$requsername";
try_files /files/$requsername /default/icons/$requsername =404;
}
location /~isucon/ {
rewrite ^/~isucon/(.*)$ /$1 break;
root /home/isucon/public_html;
}
location /shirokanezoo {
return 403;
}
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name _;
index index.html index.htm index.nginx-debian.html;
root /var/www/html;
access_log off;
# bot避けのためのvhostで、この証明書は有効期限がきれています
ssl_certificate /etc/nginx/tls/_.t.isucon.dev.crt;
ssl_certificate_key /etc/nginx/tls/_.t.isucon.dev.key;
ssl_protocols TLSv1.3;
ssl_prefer_server_ciphers off;
location / {
try_files $uri $uri/ =404;
}
}
}