Skip to content

Instantly share code, notes, and snippets.

@yctay
Created June 20, 2013 03:14
Show Gist options
  • Save yctay/5820050 to your computer and use it in GitHub Desktop.
Save yctay/5820050 to your computer and use it in GitHub Desktop.

Revisions

  1. yctay created this gist Jun 20, 2013.
    32 changes: 32 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    upstream example_name {
    server unix:///var/www/example_name/shared/sockets/puma.sock;
    }

    server {
    listen 80;
    server_name example_name.com;
    root /var/www/example_name/current/public;

    location / {

    if ($request_method = 'OPTIONS') {
    add_header 'Access-Control-Allow-Origin' $http_origin;
    add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
    add_header 'Access-Control-Allow-Headers' 'Content-Type, Accept';
    add_header 'Access-Control-Max-Age' '1728000';
    add_header 'Content-Type' 'text/plain; charset=UTF-8';
    return 200;
    }

    proxy_pass http://example_name;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location ~ ^/(assets)/ {
    root /var/www/example_name/current/public;
    gzip_static on; # to serve pre-gzipped version
    expires max;
    add_header Cache-Control public;
    }
    }