How to successfully add a "virtual host" in nginx?

I am successfully running nginx at ha.mydomain.net:

domain: ha.mydomain.net
hsts: max-age=31536000; includeSubDomains
certfile: fullchain.pem
keyfile: privkey.pem
cloudflare: false
customize:
  active: true
  default: nginx_proxy_default*.conf
  servers: nginx_proxy/*.conf

But I also want it to respond to tesla.mydomain.net. Hence I need a virtual host. I set customize.active=true and created /share/nginx_proxy/tesla_proxy.conf with following content:

server {
  #ssl on;
  #ssl_certificate      /ssl/fullchain.pem;
  #ssl_certificate_key  /ssl/privkey.pem;

  listen 443 ssl;

  server_name tesla.mydomain.net;
  location / {
    proxy_pass http://127.0.0.1:7277;
  }
}

However, nginx failed to start then and I had to use my emergency ssh login to even get back access to HA.

Why does this fail?

Could anyone share an example file how to add a virtual host to nginx add-on successfully?

That won’t work, afaik. The addon is a docker container, so 127.0.0.1 points to the addon, not HA

Try

proxy_pass: http://homeassistant.local.hass.io:7277

Ref:

Actually, you might just want to copy the whole config, just changing the server name.