1
0

huginn-ssl 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. ## Huginn
  2. ##
  3. ## Modified from nginx http version
  4. ## Modified from http://blog.phusion.nl/2012/04/21/tutorial-setting-up-gitlab-on-debian-6/
  5. ## Modified from https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
  6. ## Modified from https://github.com/gitlabhq/gitlabhq/blob/master/lib/support/nginx/gitlab-ssl
  7. ##
  8. ## Lines starting with two hashes (##) are comments with information.
  9. ## Lines starting with one hash (#) are configuration parameters that can be uncommented.
  10. ##
  11. ###################################
  12. ## configuration ##
  13. ###################################
  14. ##
  15. ## See installation.md#using-https for additional HTTPS configuration details.
  16. upstream huginn {
  17. server unix:/home/huginn/huginn/tmp/sockets/unicorn.socket fail_timeout=0;
  18. }
  19. ## Redirects all HTTP traffic to the HTTPS host
  20. server {
  21. listen 0.0.0.0:80;
  22. listen [::]:80 ipv6only=on default_server;
  23. server_name YOUR_SERVER_FQDN; ## Replace this with something like huginn.example.com
  24. server_tokens off; ## Don't show the nginx version number, a security best practice
  25. return 301 https://$server_name$request_uri;
  26. access_log /var/log/nginx/huginn_access.log;
  27. error_log /var/log/nginx/huginn_error.log;
  28. }
  29. ## HTTPS host
  30. server {
  31. listen 0.0.0.0:443 ssl;
  32. listen [::]:443 ipv6only=on ssl default_server;
  33. server_name YOUR_SERVER_FQDN; ## Replace this with something like huginn.example.com
  34. server_tokens off; ## Don't show the nginx version number, a security best practice
  35. root /home/huginn/huginn/public;
  36. ## Increase this if you want to upload large attachments
  37. ## Or if you want to accept large git objects over http
  38. client_max_body_size 20m;
  39. ## Strong SSL Security
  40. ## https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html & https://cipherli.st/
  41. ssl on;
  42. ssl_certificate /etc/nginx/ssl/huginn.crt;
  43. ssl_certificate_key /etc/nginx/ssl/huginn.key;
  44. ssl_ciphers 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4';
  45. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  46. ssl_prefer_server_ciphers on;
  47. ssl_session_cache shared:SSL:10m;
  48. ssl_session_timeout 5m;
  49. ## See app/controllers/application_controller.rb for headers set
  50. ## [Optional] If your certficate has OCSP, enable OCSP stapling to reduce the overhead and latency of running SSL.
  51. ## Replace with your ssl_trusted_certificate. For more info see:
  52. ## - https://medium.com/devops-programming/4445f4862461
  53. ## - https://www.ruby-forum.com/topic/4419319
  54. ## - https://www.digitalocean.com/community/tutorials/how-to-configure-ocsp-stapling-on-apache-and-nginx
  55. # ssl_stapling on;
  56. # ssl_stapling_verify on;
  57. # ssl_trusted_certificate /etc/nginx/ssl/stapling.trusted.crt;
  58. # resolver 208.67.222.222 208.67.222.220 valid=300s; # Can change to your DNS resolver if desired
  59. # resolver_timeout 5s;
  60. ## [Optional] Generate a stronger DHE parameter:
  61. ## sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 4096
  62. ##
  63. # ssl_dhparam /etc/ssl/certs/dhparam.pem;
  64. ## Individual nginx logs for this huginn vhost
  65. access_log /var/log/nginx/huginn_access.log;
  66. error_log /var/log/nginx/huginn_error.log;
  67. location / {
  68. ## Serve static files from defined root folder.
  69. ## @huginn is a named location for the upstream fallback, see below.
  70. try_files $uri $uri/index.html $uri.html @huginn;
  71. }
  72. ## If a file, which is not found in the root folder is requested,
  73. ## then the proxy passes the request to the upsteam (huginn unicorn).
  74. location @huginn {
  75. ## If you use HTTPS make sure you disable gzip compression
  76. ## to be safe against BREACH attack.
  77. gzip off;
  78. proxy_read_timeout 300;
  79. proxy_connect_timeout 300;
  80. proxy_redirect off;
  81. proxy_set_header Host $http_host;
  82. proxy_set_header X-Real-IP $remote_addr;
  83. proxy_set_header X-Forwarded-Ssl on;
  84. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  85. proxy_set_header X-Forwarded-Proto $scheme;
  86. proxy_set_header X-Frame-Options SAMEORIGIN;
  87. proxy_pass http://huginn;
  88. }
  89. ## Enable gzip compression as per rails guide:
  90. ## http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
  91. ## WARNING: If you are using relative urls remove the block below
  92. ## See config/application.rb under "Relative url support" for the list of
  93. ## other files that need to be changed for relative url support
  94. location /assets/ {
  95. gzip_static on; # to serve pre-gzipped version
  96. expires max;
  97. add_header Cache-Control public;
  98. }
  99. error_page 502 /502.html;
  100. }