Advertisement
freelensia

20200406 Staging Nginx Config after www stopped working

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