Update nginx config, add websocket location routing

This commit is contained in:
Felix Ableitner 2019-09-16 13:02:10 +02:00
parent a698a3d37f
commit 7dab58dc23
2 changed files with 29 additions and 1 deletions

View File

@ -17,7 +17,7 @@ services:
restart: "always" restart: "always"
peertube: peertube:
image: chocobozzz/peertube:v1.3.1-stretch image: chocobozzz/peertube:v1.4.1-stretch
env_file: env_file:
- .env - .env
volumes: volumes:

View File

@ -86,6 +86,11 @@ http {
proxy_cache_revalidate on; proxy_cache_revalidate on;
proxy_cache_lock on; proxy_cache_lock on;
#add_header X-Cached $upstream_cache_status; #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)/ { location ~ ^/static/(webseed|redundancy)/ {
# NOTE: Its not possible to use proxy_cache for files that are served from disk without complicated workarounds # 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 /; 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";
}
} }
} }