From 7dab58dc2394a53b11363cdaeb8333e5db055bf2 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 16 Sep 2019 13:02:10 +0200 Subject: [PATCH] Update nginx config, add websocket location routing --- templates/docker-compose.yml | 2 +- templates/nginx.conf | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/templates/docker-compose.yml b/templates/docker-compose.yml index 12bc4d3..35a8678 100644 --- a/templates/docker-compose.yml +++ b/templates/docker-compose.yml @@ -17,7 +17,7 @@ services: restart: "always" peertube: - image: chocobozzz/peertube:v1.3.1-stretch + image: chocobozzz/peertube:v1.4.1-stretch env_file: - .env volumes: diff --git a/templates/nginx.conf b/templates/nginx.conf index 41563d2..9af34bf 100644 --- a/templates/nginx.conf +++ b/templates/nginx.conf @@ -86,6 +86,11 @@ http { proxy_cache_revalidate on; proxy_cache_lock on; #add_header X-Cached $upstream_cache_status; + + location ~ ^/client/(.*\.(js|css|woff2|otf|ttf|woff|eot))$ { + proxy_pass http://peertube:9000; + add_header Cache-Control "public, max-age=31536000, immutable"; + } } location ~ ^/static/(webseed|redundancy)/ { # NOTE: Its not possible to use proxy_cache for files that are served from disk without complicated workarounds @@ -131,5 +136,28 @@ http { try_files $uri /; } + # Websocket tracker + location /tracker/socket { + # Peers send a message to the tracker every 15 minutes + # Don't close the websocket before this time + proxy_read_timeout 1200s; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_http_version 1.1; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_pass http://peertube:9000; + } + location /socket.io { + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + + proxy_pass http://peertube:9000; + + # enable WebSockets + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } } }