user  nobody;
worker_processes  1;

error_log  /home/webapp/loan-pricing/logs/nginx-error.log warn;
pid        /home/webapp/loan-pricing/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /home/webapp/env/nginx/conf/mime.types;
    default_type  application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /home/webapp/loan-pricing/logs/nginx-access.log  main;

    sendfile        on;
    keepalive_timeout  65;
    client_max_body_size 100m;

    server {
        listen       63311;
        server_name  _;

        root   /home/webapp/loan-pricing/frontend/dist;
        index  index.html;

        location /prod-api/ {
            proxy_pass         http://127.0.0.1:63310/;
            proxy_http_version 1.1;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Proto $scheme;
        }

        location / {
            try_files $uri $uri/ /index.html;
        }
    }
}
