maestrano/mno-enterprise

View on GitHub
core/lib/generators/mno_enterprise/install/templates/nginx.conf

Summary

Maintainability
Test Coverage
# Default MNOE nginx configuration for the web-ruby docker image used by Nex!™:
# https://github.com/maestrano/docker-web-ruby
server {
  listen 80 default_server;
  server_name _;

  root      /app/public;
  try_files $uri/index.html $uri @app;

  #-----------------------------------------------------------
  # Mnoe custom caching configuration
  #-----------------------------------------------------------
  # Empty location block to force the html block to trigger
  location ~* ^/(admin|dashboard)/$ {
  }

  # Revalidate html pages on each request and fetch the latest version if the content change
  location ~* \.(html?|json)$ {
    add_header Cache-Control "max-age=0, must-revalidate";
  }

  # Same for config.js
  location ~* config\.js$ {
    add_header Cache-Control "max-age=0, must-revalidate";
  }

  # CSS and Javascript
  # "far future expires" of 1 year as the assets are fingerprinted
  location ~* \.(?:css|js)$ {
    add_header Cache-Control "max-age=31536000";
    # access_log off;
  }

  #-----------------------------------------------------------
  # Proxy to Puma
  #-----------------------------------------------------------
  location @app {
    # # Wide-open CORS config
    # if ($request_method = 'OPTIONS') {
    #   add_header 'Access-Control-Allow-Origin' '*';
    #   add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
    #   add_header 'Access-Control-Allow-Headers' 'Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,x-csrf-token,Authorization';
    #   add_header 'Access-Control-Max-Age' 1728000;
    #   add_header 'Content-Type' 'text/plain charset=UTF-8';
    #   add_header 'Content-Length' 0;
    #   return 204;
    # }
    # if ($request_method = 'POST') {
    #   add_header 'Access-Control-Allow-Origin' '*';
    #   add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
    #   add_header 'Access-Control-Allow-Headers' 'Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,x-csrf-token,Authorization';
    # }
    # if ($request_method = 'GET') {
    #   add_header 'Access-Control-Allow-Origin' '*';
    #   add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
    #   add_header 'Access-Control-Allow-Headers' 'Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
    # }

    proxy_pass http://127.0.0.1:3000;
    proxy_redirect off;

    proxy_connect_timeout       600;
    proxy_send_timeout          600;
    proxy_read_timeout          600;
    send_timeout                600;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 10;
}