include /etc/nginx/modules-enabled.d/*.conf;

worker_processes 10;

error_log /var/log/nginx/error.log;

events {
    worker_connections 1024;
}

include /etc/nginx/conf-enabled.d/*.conf;

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

    sendfile on;

    gzip on;
    gzip_types text/plain text/css text/xml application/x-javascript application/atom+xml;

    log_format nginx_main
        '$remote_addr - $remote_user [$time_local] $request '
        '"$status" $body_bytes_sent "$http_referer" '
        '"$http_user_agent" "$http_x_forwarded_for" '
        '"$request_filename" "$gzip_ratio" $upstream_response_time server: $host : $document_root $fastcgi_script_name ';

    server {
        listen 80 default;

        access_log /var/log/nginx/access.log nginx_main;
        error_log  /var/log/nginx/error.log error;

        root /usr/share/nginx/html;
        charset utf-8;
        client_max_body_size 32m;

        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_min_length 256;
        gzip_types
            application/atom+xml
            application/geo+json
            application/javascript
            application/x-javascript
            application/json
            application/ld+json
            application/manifest+json
            application/rdf+xml
            application/rss+xml
            application/xhtml+xml
            application/xml
            font/eot
            font/otf
            font/ttf
            image/svg+xml
            text/css
            text/javascript
            text/plain
            text/xml;

        location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|mp3|ogg|ogv|webm|htc|woff2|woff|ttf)$ {
            expires 1M;
            access_log off;
            add_header Cache-Control "max-age=2629746, public";
        }

        location /ervu-eks/ {
            proxy_pass http://eks-backend:8080/ervu-eks/;
            proxy_set_header Accept application/json;
            add_header Content-Type application/json;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        location = /health {
            access_log off;
            add_header 'Content-Type' 'application/json';
            return 200 '{"status":"UP"}';
        }
    }
}
