diff --git a/Dockerfile.mod b/Dockerfile.mod index 2580207..6750c57 100644 --- a/Dockerfile.mod +++ b/Dockerfile.mod @@ -1,5 +1,7 @@ FROM nginx:mainline +ENV UDS=1 BIND_UNIX=/var/run/piped-proxy/actix.sock + WORKDIR /app/ RUN apt-get update && \ diff --git a/docker/nginx/conf.d/app.conf b/docker/nginx/conf.d/app.conf index 17b9c63..c75849f 100644 --- a/docker/nginx/conf.d/app.conf +++ b/docker/nginx/conf.d/app.conf @@ -2,17 +2,22 @@ server { listen 80; server_name _; - - location / { + location ~ (/api/v4/|/api/manifest/) { include snippets/proxy.conf; + add_header Cache-Control private always; } location ~ /videoplayback { include snippets/proxy.conf; + add_header Cache-Control private always; if ($http_user_agent ~* "com\.github\.libretube") { rewrite ^(.*)$ $1?ump=1 break; } } + location / { + include snippets/proxy.conf; + add_header Cache-Control "public, max-age=604800"; + } } \ No newline at end of file diff --git a/docker/nginx/snippets/proxy.conf b/docker/nginx/snippets/proxy.conf index d8452e1..1621d4b 100644 --- a/docker/nginx/snippets/proxy.conf +++ b/docker/nginx/snippets/proxy.conf @@ -1,9 +1,18 @@ +proxy_buffering on; +proxy_buffers 1024 16k; +proxy_set_header X-Forwarded-For ""; +proxy_set_header CF-Connecting-IP ""; +proxy_hide_header "alt-svc"; sendfile on; sendfile_max_chunk 512k; tcp_nopush on; aio threads=default; aio_write on; directio 16m; +proxy_hide_header Cache-Control; +proxy_hide_header etag; +proxy_http_version 1.1; +proxy_set_header Connection keep-alive; +proxy_max_temp_file_size 32m; # access_log off; -proxy_max_temp_file_size 32m; proxy_pass http://unix:/var/run/piped-proxy/actix.sock; \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 4e3e01f..9128d3e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,16 +27,6 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; async fn main() -> std::io::Result<()> { println!("Running server!"); - let _env_vars = ["UDS", "BIND_UNIX", "PROXY", "PROXY_USER", "PROXY_PASS"]; - for env_var in _env_vars.into_iter() { - println!( - "{var_name}: {var_value}", - var_name=env_var, - var_value=env::var(env_var) - .unwrap_or_else(|_| "NUL".to_string()) - ); - } - let server = HttpServer::new(|| { // match all requests App::new().default_service(web::to(index))