server {
  listen 80;
  server_name _;

  root /var/www/public;
  index index.php;

  # Basic hardening
  client_max_body_size 64m;

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

  location = /api/events {
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root/index.php;
    fastcgi_param SCRIPT_NAME /index.php;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param PATH_INFO /api/events;
    fastcgi_param DOCUMENT_ROOT $document_root;
    fastcgi_pass php:9000;
    fastcgi_read_timeout 3600;
    fastcgi_send_timeout 3600;
    fastcgi_keep_conn on;
    fastcgi_buffering off;
    fastcgi_cache off;
    add_header X-Accel-Buffering no;
  }

  location ~ \.php$ {
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $document_root;
    fastcgi_pass php:9000;
    fastcgi_read_timeout 300;
  }

  location ~ /(\.ht|\.git) {
    deny all;
  }
}
