events { 
  worker_connections  1024;  ## Default: 1024 
} 
 
http { 

    include /etc/nginx/mime.types; 
 
     server { 
        
        listen 8080;

        location / { 
          return 301 /docs;
        } 
 
        location /docs { 
            alias /usr/share/nginx/html;
            index /docs/index.html;
            try_files $uri $uri/ /docs/index.html?q=$query_string; 
        } 

        location = /docs/proxy/js/script.js {
            proxy_pass https://plausible.io/js/script.js;
            proxy_set_header Host plausible.io;
        }

        location = /docs/proxy/api/event {
            proxy_pass https://plausible.io/api/event;
            proxy_set_header Host plausible.io;
            proxy_buffering on;
            proxy_http_version 1.1;

            proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host  $host;
        }
    } 
 
    ## enable gzip compression 
    gzip on; 
    gzip_vary on; 
    gzip_min_length 256; 
    gzip_proxied any; 
 
    gzip_types 
      ## text/html is always compressed : https://nginx.org/en/docs/http/ngx_http_gzip_module.html 
      text/plain 
      text/css 
      text/javascript 
      application/javascript 
      application/x-javascript 
      application/xml 
      application/json 
      application/ld+json; 
}