aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-11-20 16:56:53 +0800
committercrupest <crupest@outlook.com>2022-11-20 16:56:53 +0800
commitfbc8c4e6e0e4bf52c3c954895e388c914bd04aa8 (patch)
treea3ade43e6d89f001b055c9277b70a3917023d92e
parent4a726c4a66970ddc5226538a7cca138c6526e673 (diff)
downloadcrupest-fbc8c4e6e0e4bf52c3c954895e388c914bd04aa8.tar.gz
crupest-fbc8c4e6e0e4bf52c3c954895e388c914bd04aa8.tar.bz2
crupest-fbc8c4e6e0e4bf52c3c954895e388c914bd04aa8.zip
Try to fix nginx and timeline.
-rw-r--r--template/nginx/reverse-proxy.conf.template4
-rw-r--r--template/nginx/websocket.conf4
-rwxr-xr-xtool/modules/nginx.py5
3 files changed, 10 insertions, 3 deletions
diff --git a/template/nginx/reverse-proxy.conf.template b/template/nginx/reverse-proxy.conf.template
index b17f042..2fc94b0 100644
--- a/template/nginx/reverse-proxy.conf.template
+++ b/template/nginx/reverse-proxy.conf.template
@@ -11,7 +11,9 @@ server {
proxy_pass http://${CRUPEST_NGINX_UPSTREAM_NAME};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection $http_connection;
+ proxy_set_header Connection $connection_upgrade;
+ proxy_cache off;
+ proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
diff --git a/template/nginx/websocket.conf b/template/nginx/websocket.conf
new file mode 100644
index 0000000..ac56b69
--- /dev/null
+++ b/template/nginx/websocket.conf
@@ -0,0 +1,4 @@
+map $http_connection $connection_upgrade {
+ "~*Upgrade" $http_connection;
+ default keep-alive;
+}
diff --git a/tool/modules/nginx.py b/tool/modules/nginx.py
index dbe93bb..422a823 100755
--- a/tool/modules/nginx.py
+++ b/tool/modules/nginx.py
@@ -16,7 +16,7 @@ with open(os.path.join(nginx_template_dir, 'server.schema.json')) as f:
jsonschema.validate(server, schema)
-non_template_files = ['forbid_unknown_domain.conf']
+non_template_files = ['forbid_unknown_domain.conf', "websocket.conf"]
ssl_template = Template(os.path.join(nginx_template_dir, 'ssl.conf.template'))
root_template = Template(os.path.join(
@@ -25,7 +25,8 @@ static_file_template = Template(os.path.join(
nginx_template_dir, 'static-file.conf.template'))
reverse_proxy_template = Template(os.path.join(
nginx_template_dir, 'reverse-proxy.conf.template'))
-cert_only_template = Template(os.path.join(nginx_template_dir, 'cert-only.conf.template'))
+cert_only_template = Template(os.path.join(
+ nginx_template_dir, 'cert-only.conf.template'))
nginx_var_set = set.union(root_template.var_set,
static_file_template.var_set, reverse_proxy_template.var_set)