Advertisement
freelensia

20200407 Prod Nginx Config after www stopped working on stag

Apr 8th, 2020
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.57 KB | None | 0 0
  1. upstream puma_freelensia_production {
  2.   server unix:/home/ubuntu/app/freelensia/shared/tmp/sockets/freelensia-puma.sock fail_timeout=0;
  3. }
  4.  
  5. # 20190916 Added by Trinh Tran to resolve freelensia.com not showing SSL correctly
  6. server {
  7.   listen 80;
  8.   server_name www.freelensia.com;
  9.   return 301 https://www.freelensia.com$request_uri;
  10. }
  11.  
  12. # redirect http://freelensia.com to https://www.freelensia.com
  13. server {
  14.     listen 443 ssl;
  15.     server_name freelensia.com;
  16.     ssl_certificate /etc/letsencrypt/live/www.freelensia.com/fullchain.pem; # managed by Certbot
  17.     ssl_certificate_key /etc/letsencrypt/live/www.freelensia.com/privkey.pem; # managed by Certbot
  18.     return 301 https://www.freelensia.com$request_uri;
  19. }
  20. # End of Trinh Tran add
  21.  
  22. server {
  23.   listen 80;
  24.   server_name www.freelensia.com freelensia.com;
  25.   root /home/ubuntu/app/freelensia/current/public;
  26.   try_files $uri/index.html $uri @puma_freelensia_production;
  27.  
  28.   client_max_body_size 4G;
  29.   keepalive_timeout 10;
  30.  
  31.   error_page 500 502 504 /500.html;
  32.   error_page 503 @503;
  33.  
  34.   location @puma_freelensia_production {
  35.     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  36.     proxy_set_header Host $http_host;
  37.     proxy_set_header X-Forwarded-Proto https;
  38.     proxy_redirect off;
  39.     proxy_pass http://puma_freelensia_production;
  40.     # limit_req zone=one;
  41.     access_log /home/ubuntu/app/freelensia/shared/log/nginx.access.log;
  42.     error_log /home/ubuntu/app/freelensia/shared/log/nginx.error.log;
  43.   }
  44.  
  45.   location ^~ /assets/ {
  46.     gzip_static on;
  47.     expires max;
  48.     add_header Cache-Control public;
  49.   }
  50.  
  51.   location = /50x.html {
  52.     root html;
  53.   }
  54.  
  55.   location = /404.html {
  56.     root html;
  57.   }
  58.  
  59.   location @503 {
  60.     error_page 405 = /system/maintenance.html;
  61.     if (-f $document_root/system/maintenance.html) {
  62.       rewrite ^(.*)$ /system/maintenance.html break;
  63.     }
  64.     rewrite ^(.*)$ /503.html break;
  65.   }
  66.  
  67.   if ($request_method !~ ^(GET|HEAD|PUT|PATCH|POST|DELETE|OPTIONS)$ ){
  68.     return 405;
  69.   }
  70.  
  71.   if (-f $document_root/system/maintenance.html) {
  72.     return 503;
  73.   }
  74.  
  75.     listen 443 ssl http2; # managed by Certbot
  76. ssl_certificate /etc/letsencrypt/live/www.freelensia.com/fullchain.pem; # managed by Certbot
  77. ssl_certificate_key /etc/letsencrypt/live/www.freelensia.com/privkey.pem; # managed by Certbot
  78.     include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  79.  
  80.     # Redirect non-https traffic to https
  81. # 20190916 Commented out by Trinh Tran below
  82. # if ($scheme != "https") {
  83. #      return 301 https://$host$request_uri;
  84. #   } # managed by Certbot
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement