server {
    listen 443 ssl; # Added ssl here
    server_name dracs.example.com;

    ssl_certificate /etc/pki/tls/certs/dracs.example.com.pem;
    ssl_certificate_key /etc/pki/tls/certs/dracs.example.com.key;

    # Recommended SSL settings
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;

    # Display TSR reports
    location /tsr {
        alias /var/lib/dracs/web/tsr/;
        autoindex on;
        autoindex_exact_size off; # Optional: Shows file sizes in KB/MB/GB instead of byte
        autoindex_localtime on;  # Optional: Shows file times in your local timezone
    }

    # VNC Console WebSocket proxy (requires VNC_ENABLE=true)
    location /websockify {
        proxy_pass http://127.0.0.1:6080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_read_timeout 1800;
    }

    location / {
        proxy_pass http://127.0.0.1:1888;

        # Headers to ensure Flask knows it's behind a proxy
        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;

        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 86400;
    }
}
