worker_processes auto;
pid /run/nginx/nginx.pid;
error_log /dev/stderr warn;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /dev/stdout;
    sendfile on;
    tcp_nopush on;
    keepalive_timeout 65;
    server_tokens off;
    client_max_body_size 64M;   # ticket attachments, receipts, theme uploads

    gzip on;
    gzip_types text/css application/javascript application/json image/svg+xml;

    server {
        listen 8080 default_server;
        listen [::]:8080 default_server;
        server_name _;

        root /var/www/html/public;
        index index.php;
        charset utf-8;

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

        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }
        location = /up          { access_log off; try_files $uri /index.php?$query_string; }

        location /build/ {
            expires 1y;
            add_header Cache-Control "public, immutable";
            try_files $uri =404;
        }

        location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            include fastcgi_params;
            fastcgi_read_timeout 120s;
        }

        location ~ /\.(?!well-known).* { deny all; }
    }
}
