log_format compression '$remote_addr - $remote_user [$time_local] "$request" '
                       '$status $body_bytes_sent "$http_referer" '
                       '"$http_user_agent" "$http_x_forwarded_for" '
                       '$request_time $upstream_response_time $pipe $upstream_cache_status';

server {
    listen 80;
    listen [::]:80;

    root /var/www/public;
    server_name localhost;
    index index.php index.html;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
    add_header X-XSS-Protection "1; mode=block";

    charset utf-8;
    server_tokens off;
    keepalive_timeout 75;
    tcp_nopush on;
    tcp_nodelay on;
    sendfile off;

    #access_log /var/www/deployment/nginx/logs/access.log compression;
    #error_log /var/www/deployment/nginx/logs/error.log;
    error_log /dev/stdout info;
    access_log  /dev/stdout main;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
        gzip_static on;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass web:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        include fastcgi_params;
    }

    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
        expires max;
        add_header Cache-Control public;
        log_not_found off;
        access_log off;
        error_log off;

        # 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;
    }

    location ~ /\. {
        log_not_found off;
        deny all;
    }
}
