Domain and subdomains with nginx from the same server

More dev than ops here. Situation: I have a home server (fedora) running a few applications using podman. Some are database services and use various ports. Can this work in NGINX?

  • host personal site through domain.dev. It lives on localhost:8080.
  • host the Fedora cockpit through cocking.domain.dev. It lives on localhost:9090.
  • host the other applications through sub domains of their own, with their various ports db.domain.dev:30001 which live on localhost:30001. I think I have 15 ports used all in all.

Cockpit I think I can do (it uses websockets)

map $http_upgrade $connection_upgrade {
  default upgrade;
  '' close;
}
upstream websocket {
  server localhost:9090;
}
server {
  server_name cockpit.domain.dev;
  location / {
    proxy_pass http://websocket;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Origin https://$host;
  }
}

Can I simply add another location / for domain domain.dev?

I can open my modem to pass on all the required ports. If possible, I have a follow-up question later about certbot, google domains and google dns. I cannot get that to work.