deminart

nginx vaultwarden

Mar 18th, 2024
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. # The `upstream` directives ensure that you have a http/1.1 connection This enables the keepalive option and better performance
  2. #
  3. # Define the server IP and ports here.
  4. upstream vaultwarden-default {
  5. zone vaultwarden-default 64k;
  6. server 127.0.0.1:8088;
  7. keepalive 2;
  8. }
  9.  
  10. # Needed to support websocket connections See: https://nginx.org/en/docs/http/websocket.html Instead of "close" as stated in the above link we send an empty value. Else all keepalive connections will
  11. # not work.
  12. map $http_upgrade $connection_upgrade {
  13. default upgrade;
  14. '' "";
  15. }
  16.  
  17. # Redirect HTTP to HTTPS
  18. server {
  19. listen 80;
  20. listen [::]:80;
  21. server_name pass.sam.host;
  22. if ($host = pass.sam.host) {
  23. return 301 https://$host$request_uri;
  24. }
  25. return 404;
  26. }
  27.  
  28. server {
  29. # For older versions of nginx appened http2 to the listen line after ssl and remove `http2 on`
  30. listen 443 ssl;
  31. listen [::]:443 ssl;
  32. server_name pass.sam.host;
  33. # http2 on; server_name pass.sam.host;
  34. # Specify SSL Config when needed
  35. ssl_certificate /etc/nginx/ssl/cert.pem;
  36. ssl_certificate_key /etc/nginx/ssl/key.pem;
  37. client_max_body_size 525M;
  38. proxy_max_temp_file_size 0;
  39. location / {
  40. proxy_http_version 1.1;
  41. proxy_set_header Upgrade $http_upgrade;
  42. proxy_set_header Connection $connection_upgrade;
  43.  
  44. proxy_set_header Host $host;
  45. proxy_set_header X-Real-IP $remote_addr;
  46. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  47. proxy_set_header X-Forwarded-Proto $scheme; proxy_pass
  48.  
  49. http://172.26.8.203:8088/;
  50. }
  51.  
  52. # Optionally add extra authentication besides the ADMIN_TOKEN Remove the comments below `#` and create the htpasswd_file to have it active
  53. #
  54. #location /admin {
  55. # # See: https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/
  56. # auth_basic "Private"; auth_basic_user_file /path/to/htpasswd_file;
  57. #
  58. # proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade;
  59. #
  60. # proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme;
  61. #
  62. # proxy_pass http://vaultwarden-default;
  63. #}
  64. }
  65.  
  66.  
Add Comment
Please, Sign In to add comment