Nginx and homeassistant issue

I am new to nginx and I am trying to combine multiple systems(including home assistant) under one website. If I use the first example, home assistant pops up and is super happy.

https://localhost -> ha [Good]

location / {
        proxy_pass https://127.0.0.1:8123;
        proxy_set_header Host $host;
        proxy_redirect http:// https://;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

}

With the second config

https://localhost -> 410 [Good]
https://localhost/ha -> 301 [meh]
https://localhost/ha/ -> 404 [Bad]
https://localhost:8123 -> ha [Good]

location / {
       return 410;
}

location /ha/ {
        proxy_pass https://127.0.0.1:8123;
        proxy_set_header Host $host;
        proxy_redirect http:// https://;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

}

Not sure what I have done wrong here.

301 is not an error.
It is a permanent redirect
next time post your full config. people asking questions and missing out config such as server and other relevant data means we have to guess and … well I can’t be bothered if you can’t