Advertisement
Guest User

Untitled

a guest
Feb 11th, 2020
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. server {
  2. listen 80;
  3. listen [::]:80;
  4.  
  5. server_name unifi.myhostname.com;
  6.  
  7. location / {
  8. return 301 https://$host$request_uri;
  9. }
  10.  
  11. # If they come here using HTTP, bounce them to the correct scheme
  12. error_page 497 https://$server_name:$server_port$request_uri;
  13. }
  14.  
  15. server {
  16. # SSL configuration
  17. #
  18. listen 443 ssl default_server;
  19. listen [::]:443 ssl default_server;
  20.  
  21. server_name unifi.myhostname.com;
  22.  
  23.  
  24. ssl_certificate /etc/apache2/ssl/certificate.pem;
  25. ssl_certificate_key /etc/apache2/ssl/certificate.key;
  26.  
  27. # Use only TLS
  28. ssl_protocols TLSv1.2;
  29. # Tell client which ciphers are available
  30. ssl_prefer_server_ciphers on;
  31. ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;
  32. # Use our own DH params
  33. ssl_dhparam /etc/nginx/certs/dhparam.pem;
  34. # Enable OCSP stapling
  35. ssl_stapling on;
  36. ssl_stapling_verify on;
  37. ssl_trusted_certificate /etc/apache2/ssl/certificate.pem;
  38. # Enable HSTS
  39. add_header Strict-Transport-Security "max-age=31536000" always;
  40. # Optimize session cache
  41. ssl_session_cache shared:SSL:40m;
  42. ssl_session_timeout 4h;
  43. # Enable session tickets
  44. ssl_session_tickets on;
  45.  
  46. access_log /var/log/nginx/$server_name.log;
  47.  
  48. #Allow certain IP's only else basic auth
  49. satisfy any;
  50. include /etc/nginx/IPwhitelist.conf;
  51. deny all;
  52. #Basic Auth
  53. auth_basic "Restricted";
  54. auth_basic_user_file /etc/nginx/.htpasswd;
  55.  
  56.  
  57. # Needed to allow the websockets to forward well.
  58. # Information adopted from here: https://community.ubnt.com/t5/EdgeMAX/Access-Edgemax-gui-via-nginx-reverse-proxy-websocket-problem/td-p/1544354
  59. location /wss/ {
  60. proxy_pass https://elementsdns:8443;
  61. proxy_http_version 1.1;
  62. proxy_buffering off;
  63. proxy_set_header Upgrade $http_upgrade;
  64. proxy_set_header Connection "Upgrade";
  65. proxy_read_timeout 86400;
  66. }
  67.  
  68. location / {
  69. proxy_set_header Authorization "";
  70. proxy_pass https://elementsdns:8443/; # The Unifi Controller Port
  71. proxy_set_header Host $host;
  72. proxy_set_header X-Real-IP $remote_addr;
  73. proxy_set_header X-Forwarded-Host $host;
  74. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  75. proxy_set_header X-Forwarded-Proto $scheme;
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement