events {}

http {
    # Docker internal DNS resolver (IMPORTANT)
    resolver 127.0.0.11 ipv6=off;

    # HTTP server (port 80)
    server {
        listen 80;

        server_name ~^(?<subdomain>.+)\.softechigh\.tech$;

        location / {
            proxy_pass http://$subdomain:3000;

            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }

    # HTTP server (port 80)
    # PORT 5000
    server {
        listen 5000;

        server_name ~^(?<subdomain>.+)\.softechigh\.tech$;

        location / {
            proxy_pass http://$subdomain:5000;
        }
    }

    
    # PORT 8000
    server {
        listen 8000;

        server_name ~^(?<subdomain>.+)\.softechigh\.tech$;

        location / {
            proxy_pass http://$subdomain:8000;
        }
    }

    # HTTPS server (port 443)
#	server {
#	    listen 443 ssl;
#
#	    server_name ~^(?<subdomain>.+)\.softechigh\.tech$;
#
#	    ssl_certificate     /etc/nginx/certs/fullchain.pem;
#	    ssl_certificate_key /etc/nginx/certs/privkey.pem;
#
#	    location / {
#	        proxy_pass http://$subdomain:3000;
#
#	        proxy_set_header Host $host;
#	        proxy_set_header X-Real-IP $remote_addr;
#	        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#	    }
#	}
}