user app;
worker_processes auto;
pid /run/nginx.pid;

events {
  worker_connections 1024;
}

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 300;
    types_hash_max_size 2048;
    server_tokens off;
    server_names_hash_bucket_size 64;
    server_name_in_redirect off;
    client_body_in_file_only clean;
    client_body_buffer_size 32K;
    client_max_body_size 100M;
    send_timeout 300s;
    large_client_header_buffers 4 8k;

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

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

    log_format host '$remote_addr - $remote_user [$time_local] "[$host] $request" $status $bytes_sent "$http_referer" "$http_user_agent" "$gzip_ratio"';
    access_log /var/log/acces.log host;
    error_log stderr;

    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    # if x-forwarded-proto header is set to https keep the header
    map $http_x_forwarded_proto $real_proto {
        default "http";
        "https" "https";
    }

    server {
        listen 4848;
        listen [::]:4848;
        server_name _;

        root /docs;
        index index.html;

        proxy_buffers 32 4k;
        proxy_set_header Connection "";

        location / {
            proxy_pass http://127.0.0.1:8080;
            proxy_set_header Host localhost;
            proxy_set_header X-Forwarded-Proto $real_proto;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_redirect off;
            proxy_read_timeout 59;
            proxy_connect_timeout 10;
        }
    }
}
