worker_processes 1;
events { worker_connections 1024; }

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;

    server {
        listen 8085;
        server_name localhost;
        root /app/static;

        location = / {
            return 301 /dashboard.html;
        }

        location / {
            try_files $uri $uri/ =404;
            add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
        }

        location /api/auth {
            proxy_pass http://127.0.0.1:8086;
            proxy_http_version 1.1;
            proxy_set_header Host $host;
        }

        location /api/settings {
            proxy_pass http://127.0.0.1:8086;
            proxy_http_version 1.1;
            proxy_set_header Host $host;
            proxy_set_header Authorization $http_authorization;
        }

        location /api/mail {
            proxy_pass http://127.0.0.1:8087;
            proxy_http_version 1.1;
            proxy_set_header Host $host;
        }

        location /proxy {
            proxy_pass http://127.0.0.1:8088;
            proxy_http_version 1.1;
            proxy_set_header Host $host;
        }

        location /health {
            proxy_pass http://127.0.0.1:8086;
        }
    }
}
