Guest User

Untitled

a guest
Nov 20th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. #Redirect http www to https no-www
  2. server {
  3. server_name _;
  4. access_log off;
  5. }
  6.  
  7. #Redirect http no-www to https no-www
  8. server {
  9. // listening to port 80
  10. listen "actual-server-ip";
  11. listen [::]:80;
  12. server_name localhost;
  13. root /home/maindir;
  14. index index.php;
  15. access_log off;
  16. port_in_redirect off;
  17.  
  18. location / {
  19. allow 127.0.0.1;
  20. auth_basic "Please enter username";
  21. auth_basic_user_file /etc/nginx/.passfile1;
  22. }
  23.  
  24. }
  25.  
  26. server {
  27. // listening to port 443 for https requests
  28. listen 443 ssl default_server;
  29. listen [::]:443 ssl default_server;
  30. server_name localhost;
  31. port_in_redirect off;
  32. access_log off;
  33. ssl_certificate /main/ssl/eth0___localhost.pem;
  34. ssl_certificate_key /main/ssl/eth0___localhost.key;
  35. ssl_trusted_certificate /main/ssl/eth0___localhost.ca;
  36. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  37. ssl_dhparam /root/dhparams.pem;
  38. ssl_prefer_server_ciphers on;
  39. ssl_ecdh_curve secp384r1;
  40. root /home/maindir;
  41. add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
  42. add_header X-Frame-Options SAMEORIGIN;
  43. add_header X-Content-Type-Options nosniff;
  44. index index.php index.html index.htm;
  45.  
  46. location / {
  47. proxy_pass http://127.0.0.1:81; // to direct requests to varnish
  48. proxy_set_header X-Real-IP $remote_addr;
  49. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  50. proxy_set_header X-Forwarded-Proto https;
  51. proxy_set_header X-Forwarded-Port 443;
  52. proxy_set_header Host $http_host;
  53. proxy_set_header X-Forwarded-Host $http_host;
  54. proxy_set_header HTTPS "on";
  55. proxy_read_timeout 90;
  56. proxy_connect_timeout 90;
  57. proxy_redirect off;
  58. }
  59.  
  60. location ~ /.ht {
  61. deny all;
  62. }
  63.  
  64. }
Add Comment
Please, Sign In to add comment