server {
        listen       80;
        server_name  www.weiling.co;
        rewrite ^ http://weiling.co$request_uri? permanent;
        }

server {
        listen       80;
        server_name weiling.co;
        root   /www/weiling-company/current/public;        

        location ~ ^/images/ {
                gzip_static on;
                expires max;
                add_header Cache-Control public;
                break;
         }

        location ~ ^/assets/ {
                gzip_static on;
                expires max;
                add_header Cache-Control public;
                break;
        }

        location ~ ^/static/ {
                gzip_static on;
                expires max;
                add_header Cache-Control public;
                break;
        }

        location ~ ^/system/uploads/ {
                gzip_static on;
                expires max;
                add_header Cache-Control public;
                break;
        }


        location / {
                index  index.html index.htm;
                
                proxy_redirect     off;

                proxy_set_header   Host             $host;
                proxy_set_header   X-Real-IP        $remote_addr;
                proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_connect_timeout      90;
                proxy_send_timeout         90;
                proxy_read_timeout         90;

                proxy_buffer_size          4k;
                proxy_buffers              4 32k;
                proxy_busy_buffers_size    64k;
                proxy_temp_file_write_size 64k;
                proxy_temp_path            /tmp/nginx-proxy_temp;
                try_files $uri /page_cache/$uri /page_cache/$uri.html @unicorn;

        }

        location @unicorn {
                proxy_pass    http://127.0.0.1:4000/;
                break;
        }        

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
                root   html;
        }

}
