-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
106 lines (91 loc) · 3.05 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
daemon off;
worker_processes auto;
events {}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache:10m inactive=600s max_size=100m;
# Limit post requests
map $request_method $limit {
default "";
POST $binary_remote_addr;
}
# Creates 10mb zone in memory for storing binary IPs
limit_req_zone $limit zone=post_limit:10m rate=11r/m;
upstream http_backend {
keepalive 20;
server 127.0.0.1:8080;
}
server {
listen 80;
server_name _; # Put your own domain here
set $prefix "/opt/schemebbs";
# Site root, a static page
location = / {
rewrite ^ /static/index.html;
}
location = /favicon.ico {
rewrite ^ /static/favicon.ico;
}
location /static/ {
alias $prefix/static/;
}
# Serve S-expressions as static files
location /sexp {
alias $prefix/data/sexp/;
autoindex on;
default_type text/x-scheme;
fancyindex on;
fancyindex_time_format "%F %R";
fancyindex_footer "/static/lisp.html";
}
location / {
root $prefix/data/html;
default_type text/html;
index index;
try_files $uri $uri/index @schemebbs;
}
# Replace CSS and add query string to all internal links
if ( $query_string = "" ) {
set $bypass "1";
}
subs_filter_bypass $bypass;
subs_filter '<LINK href="/static/styles/(.*?).css"' '<LINK href="/static/styles/$arg_css.css"' or;
subs_filter '<A href="((?!http).*?)(#.*?)?"' '<A href="$1$is_args$args$2"' gr;
subs_filter '<FORM action="(.*?post)"' '<FORM action="$1$is_args$args"' gr;
location @schemebbs {
proxy_intercept_errors on;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Accept-Encoding "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Clacks-Overhead "GNU John McCarthy";
proxy_cache cache;
proxy_cache_key $scheme$host$request_method$request_uri;
proxy_cache_valid 200 30s;
proxy_pass http://http_backend;
}
error_page 400 /400.html;
error_page 403 /403.html;
error_page 404 /404.html;
error_page 405 /405.html;
error_page 429 /429.html;
error_page 500 /500.html;
error_page 502 /502.html;
error_page 503 /503.html;
error_page 504 /504.html;
location ~ ^/(400|403|404|405|429|500|502|503|504)\.html {
root $prefix/static/errors;
}
}
}
# Local Variables:
# indent-tabs-mode: nil
# tab-width: 4
# End: