|
|
@ -59,6 +59,10 @@ proxy_set_header X-Real-IP $remote_addr; |
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
|
|
proxy_redirect off; |
|
|
|
proxy_redirect off; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Cache for Invidious. |
|
|
|
|
|
|
|
# Use a maximum of 512GB for the cache which will be valid for 31 days. |
|
|
|
|
|
|
|
proxy_cache_path /etc/nginx/cache levels=1:2 use_temp_path=off keys_zone=invidious_videos_cache:10m inactive=31d max_size=16g; |
|
|
|
|
|
|
|
|
|
|
|
server { |
|
|
|
server { |
|
|
|
listen ${NGINX_LISTEN_PORT}; |
|
|
|
listen ${NGINX_LISTEN_PORT}; |
|
|
|
server_name ${BG_HOSTNAME}; |
|
|
|
server_name ${BG_HOSTNAME}; |
|
|
@ -129,4 +133,30 @@ server { |
|
|
|
return 200 "User-agent: *\nDisallow: /\n"; |
|
|
|
return 200 "User-agent: *\nDisallow: /\n"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Cache videos |
|
|
|
|
|
|
|
# Credits: @leonklingele |
|
|
|
|
|
|
|
# See: https://github.com/iv-org/invidious/issues/260#issuecomment-518138476 |
|
|
|
|
|
|
|
location ~ /(latest_version|videoplayback) { |
|
|
|
|
|
|
|
proxy_pass http://invidious; |
|
|
|
|
|
|
|
proxy_http_version 1.1; |
|
|
|
|
|
|
|
proxy_set_header Connection ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Do not remove the following directives. |
|
|
|
|
|
|
|
# Otherwise the cache will not be populated. |
|
|
|
|
|
|
|
proxy_ignore_headers Cache-Control; |
|
|
|
|
|
|
|
proxy_ignore_headers Expires; |
|
|
|
|
|
|
|
proxy_ignore_headers X-Accel-Expires; |
|
|
|
|
|
|
|
proxy_hide_header Cache-Control; |
|
|
|
|
|
|
|
proxy_hide_header Expires; |
|
|
|
|
|
|
|
proxy_hide_header Pragma; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_header X-Cache-Status $upstream_cache_status; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proxy_cache invidious_videos_cache; |
|
|
|
|
|
|
|
proxy_cache_key "invidious_videos-$request_uri"; |
|
|
|
|
|
|
|
proxy_cache_methods GET; |
|
|
|
|
|
|
|
proxy_cache_valid 200 31d; # Used for /videoplayback responses |
|
|
|
|
|
|
|
proxy_cache_valid 302 31d; # Used for /latest_version responses |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|