server {
    listen 3000;
    server_name _;
    absolute_redirect off;

    root /usr/share/nginx/html;
    index index.html;

    location = / {
        try_files /index.html =404;
    }

    location = /index.html {
        return 302 /;
    }

    location = /login {
        try_files /html/login.html =404;
    }

    location = /agents {
        try_files /html/agents.html =404;
    }

    location = /api-keys {
        try_files /html/api-keys.html =404;
    }

    location = /secrets {
        try_files /html/secrets.html =404;
    }

    location = /logs {
        try_files /html/logs.html =404;
    }

    location = /usage {
        try_files /html/usage.html =404;
    }

    location = /stream-sessions {
        try_files /html/stream-sessions.html =404;
    }

    location = /async-jobs {
        try_files /html/async-jobs.html =404;
    }

    location = /settings {
        try_files /html/settings.html =404;
    }

    location = /workspace-setup {
        try_files /html/workspace-setup.html =404;
    }

    location = /wizard {
        return 302 /wizard/;
    }

    location = /wizard/ {
        try_files /html/wizard/index.html =404;
    }

    location ~ ^/wizard/(.+)$ {
        rewrite ^/wizard/(.+)$ /html/wizard/$1 break;
        try_files $uri =404;
    }

    location = /html/login.html {
        return 302 /login;
    }

    location = /html/agents.html {
        return 302 /agents;
    }

    location = /html/api-keys.html {
        return 302 /api-keys;
    }

    location = /html/secrets.html {
        return 302 /secrets;
    }

    location = /html/logs.html {
        return 302 /logs;
    }

    location = /html/usage.html {
        return 302 /usage;
    }

    location = /html/stream-sessions.html {
        return 302 /stream-sessions;
    }

    location = /html/async-jobs.html {
        return 302 /async-jobs;
    }

    location = /html/settings.html {
        return 302 /settings;
    }

    location = /html/workspace-setup.html {
        return 302 /workspace-setup$is_args$args;
    }

    location = /html/wizard/ {
        return 302 /wizard/$is_args$args;
    }

    location = /html/wizard/index.html {
        return 302 /wizard/;
    }

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