-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
240 lines (221 loc) · 8.21 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
#user html;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
load_module /usr/lib/nginx/modules/ndk_http_module.so;
load_module /usr/lib/nginx/modules/ngx_http_fancyindex_module.so;
load_module /usr/lib/nginx/modules/ngx_http_dav_ext_module.so;
load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;
events {
worker_connections 1024;
accept_mutex off;
multi_accept on;
use epoll;
}
http {
include include/fmt/mime;
default_type application/octet-stream;
types_hash_max_size 4096;
lua_package_path '${prefix}lua/?.lua;;';
#lua_load_resty_core off;
#server_names_hash_bucket_size 128;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
init_by_lua_file lua/init.lua;
#access_log logs/access.log main;
sendfile on;
sendfile_max_chunk 512k;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
keepalive_requests 10;
ssi on;
include include/config/gzip.conf;
aio threads;
include include/config/maps.conf;
open_file_cache max=1000 inactive=2m;
open_file_cache_valid 1m;
open_file_cache_min_uses 1;
open_file_cache_errors on;
read_ahead 1m;
directio 1m;
proxy_intercept_errors on;
include include/config/error.conf;
limit_req_zone $binary_remote_addr zone=notif:16m rate=10r/m;
limit_req_zone $binary_remote_addr zone=api:8m rate=10r/s;
server {
server_name localhost;
listen 80;
listen [::]:80 default_server;
charset utf-8;
source_charset utf-8;
#access_log logs/host.access.log main;
include include/config/locations.conf;
root /srv/http;
fancyindex_header /static/header.html subrequest;
fancyindex_footer /static/footer.html subrequest;
fancyindex_hide_parent_dir on;
fancyindex_name_length 255;
fancyindex_exact_size off;
fancyindex_show_path off;
fancyindex_ignore lost+found \$RECYCLE.BIN "bootsqm.dat"
pagefile.sys "System Volume Information"
".vmdk$" ".vdi$" "^00update$" "^ln-sites.txt$";
location / {
index index.html index.htm;
}
location /repo/ {
fancyindex on;
include include/config/indexing.conf;
index index.html index.htm;
}
location /gists/ {
charset utf-8;
fancyindex on;
index index.html index.htm index.md;
}
location /files/ {
charset utf-8;
fancyindex on;
dav_ext_methods PROPFIND OPTIONS;
dav_access all:r;
include include/config/indexing.conf;
index index.html index.htm;
}
location ~ ^/dl/ {
charset utf-8;
autoindex on;
allow all;
add_header Cache-Control "no-cache" always;
}
location ~ ^/json/ {
allow all;
autoindex on;
charset utf-8;
autoindex_format json;
add_header Cache-Control "no-cache" always;
add_header X-Index "json";
add_header Access-Control-Allow-Origin *;
}
location ~ ^/xml/ {
autoindex on;
charset utf-8;
autoindex_format xml;
add_header X-Index "xml";
add_header Cache-Control "no-cache" always;
add_header Access-Control-Allow-Origin *;
}
location /locked {
add_header Content-Type text/plain;
content_by_lua_file lua/islocked.lua;
}
location /notify {
limit_req zone=notif burst=10;
add_header Content-Type text/plain;
content_by_lua_file lua/notif.lua;
}
location /error {
default_type text/html;
include include/config/return.conf;
}
# location ~ \.php(/|$) {
# fastcgi_split_path_info ^(.+?\.php)(/.*)$;
# fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
# # fastcgi_pass localhost:9000; # using TCP/IP stack
# if (!-f $document_root$fastcgi_script_name) {
# return 404;
# }
# try_files $uri $uri/ /index.php?$args;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# include include/params/fastcgi;
# }
location = /debug {
content_by_lua_block {
local h = ngx.req.get_headers()
for k, v in pairs(h) do
ngx.say(k..": "..v)
end
ngx.say(ngx.var.remote_addr)
}
}
location = /error.html {
internal;
allow all;
ssi on;
auth_basic off;
charset utf-8;
add_header Cache-Control "no-cache" always;
if ($status ~ '^3' ) { set $status_text 'Go Away.';set $status_type 'Redirection';set $status_cow 'borg';}
if ($status ~ '^4' ) { set $status_text 'You Fucked Up.';set $status_type 'Client error';set $status_cow 'tired';}
if ($status ~ '^5' ) { set $status_text 'I Fucked Up.';set $status_type 'Server error';set $status_cow 'dead';}
set $status_msg '';
access_by_lua_block {
local text = ngx.var.status_text;
ngx.var.status_msg = ngx.escape_uri(text);
}
expires -1;
root /srv/http/static;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.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 include/params/fastcgi;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
server {
server_name r u;
location / {
return 301 https://reddit.com/$host$request_uri;
}
#
#
}
# 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 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}