Advertisement
Guest User

Untitled

a guest
Nov 15th, 2024
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.84 KB | None | 0 0
  1. server {
  2. if ($host = MY_DOMAIN) {
  3. return 301 https://$host$request_uri;
  4. } # managed by Certbot
  5.  
  6.  
  7. listen 80;
  8. listen [::]:80;
  9. server_name MY_DOMAIN;
  10.  
  11. # Uncomment to redirect HTTP to HTTPS
  12. return 301 https://$host$request_uri;
  13.  
  14.  
  15. }
  16.  
  17. server {
  18. # Nginx versions prior to 1.25
  19. listen 443 ssl http2;
  20. listen [::]:443 ssl http2;
  21.  
  22. # Nginx versions 1.25+
  23. #listen 443 ssl;
  24. #listen [::]:443 ssl;
  25. #http2 on;
  26.  
  27. server_name MY_DOMAIN;
  28.  
  29. ## The default `client_max_body_size` is 1M, this might not be enough for some posters, etc.
  30. client_max_body_size 20M;
  31.  
  32. # Uncomment next line to Disable TLS 1.0 and 1.1 (Might break older devices)
  33. ssl_protocols TLSv1.3 TLSv1.2;
  34. ssl_certificate /etc/letsencrypt/live/MY_DOMAIN/fullchain.pem; # managed by Certbot
  35. ssl_certificate_key /etc/letsencrypt/live/MY_DOMAIN/privkey.pem; # managed by Certbot
  36. include /etc/letsencrypt/options-ssl-nginx.conf;
  37. ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
  38. ssl_trusted_certificate /etc/letsencrypt/live/MY_DOMAIN/chain.pem;
  39.  
  40. # use a variable to store the upstream proxy
  41. # in this example we are using a hostname which is resolved via DNS
  42. # (if you aren't using DNS remove the resolver line and change the variable to point to an IP address e.g `set $jellyfin 127.0.0.1`)
  43. set $jellyfin jellyfin;
  44. resolver 127.0.0.1 valid=30s;
  45.  
  46. # Security / XSS Mitigation Headers
  47. # NOTE: X-Frame-Options may cause issues with the webOS app
  48. add_header X-Frame-Options "SAMEORIGIN";
  49. add_header X-Content-Type-Options "nosniff";
  50.  
  51. # Permissions policy. May cause issues with some clients
  52. add_header Permissions-Policy "accelerometer=(), ambient-light-sensor=(), battery=(), bluetooth=(), camera=(), clipboard-read=(), display-capture=(), document-domain=(), encrypted-media=(), gamepad=(), geolocation=(), gyroscope=(), hid=(), idle-detection=(), interest-cohort=(), keyboard-map=(), local-fonts=(), magnetometer=(), microphone=(), payment=(), publickey-credentials-get=(), serial=(), sync-xhr=(), usb=(), xr-spatial-tracking=()" always;
  53.  
  54. # Content Security Policy
  55. # See: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
  56. # Enforces https content and restricts JS/CSS to origin
  57. # External Javascript (such as cast_sender.js for Chromecast) must be whitelisted.
  58. # NOTE: The default CSP headers may cause issues with the webOS app
  59. add_header Content-Security-Policy "default-src https: data: blob: ; img-src 'self' https://* ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' https://www.gstatic.com https://www.youtube.com blob:; worker-src 'self' blob:; connect-src 'self'; object-src 'none'; frame-ancestors 'self'";
  60.  
  61. location / {
  62. # Proxy main Jellyfin traffic
  63. proxy_pass http://$jellyfin:8096;
  64. proxy_set_header Host $host;
  65. proxy_set_header X-Real-IP $remote_addr;
  66. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  67. proxy_set_header X-Forwarded-Proto $scheme;
  68. proxy_set_header X-Forwarded-Protocol $scheme;
  69. proxy_set_header X-Forwarded-Host $http_host;
  70.  
  71. # Disable buffering when the nginx proxy gets very resource heavy upon streaming
  72. proxy_buffering off;
  73. }
  74.  
  75. location /socket {
  76. # Proxy Jellyfin Websockets traffic
  77. proxy_pass http://$jellyfin:8096;
  78. proxy_http_version 1.1;
  79. proxy_set_header Upgrade $http_upgrade;
  80. proxy_set_header Connection "upgrade";
  81. proxy_set_header Host $host;
  82. proxy_set_header X-Real-IP $remote_addr;
  83. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  84. proxy_set_header X-Forwarded-Proto $scheme;
  85. proxy_set_header X-Forwarded-Protocol $scheme;
  86. proxy_set_header X-Forwarded-Host $http_host;
  87. }
  88.  
  89.  
  90. }
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement