rifkyekayama
6/11/2017 - 11:09 AM

nginx configuration

nginx configuration

upstream app_name {
  server unix:///tmp/app_name.sock;
}

server {
  listen 80;
  server_name www.example.com;
  return 301 $scheme://example.com$request_uri;
}

server {
  listen 80;
  listen 443;
  ssl on;
  ssl_certificate /etc/nginx/ssl/app_name.crt;
  ssl_certificate_key /etc/nginx/ssl/app_name.key;

  server_name example.com; # change to match your URL
  root /rails/app/folder/public; # I assume your app is located at that location

  location / {
    proxy_pass http://app_name; # match the name of upstream directive which is defined above
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Ssl on;
  }

  location ~* ^/assets/ {
    # Per RFC2616 - 1 year maximum expiry
    expires 1y;
    add_header Cache-Control public;

    # Some browsers still send conditional-GET requests if there's a
    # Last-Modified header or an ETag header even if they haven't
    # reached the expiry date sent in the Expires header.
    add_header Last-Modified "";
    add_header ETag "";
    break;
  }
}