Hacker News new | ask | show | jobs
by qurren 52 days ago
URLs already have default ports for service names as a feature.

http:// means port 80 unless specified otherwise

https:// means port 443 unless specified otherwise

ftp:// means port 21 unless specified otherwise

sftp:// means port 22 unless specified otherwise

...

The practical solution for TFA is actually just an nginx server running on port 80 with proxy_pass

    location /blog/ {
        proxy_pass http://127.0.0.1:3000 ;
    }

    location /tensorboard/ {
        proxy_pass http://127.0.0.1:6006;
    }
...
2 comments

How many little web servers work without issue when their root page is loaded from a path other than /?
If that's your concern you can also do this

    server {
        listen 80;
        server_name "tensorboard.localhost";
        location / {
            proxy_pass http://127.0.0.1:6006;
        }
    }

    server {
        listen 80;
        server_name "blog.localhost";
        location / {
            proxy_pass http://127.0.0.1:3000;
        }
    }
HTTP 1.1 and later will have the browser supply the domain name that was used to access the site, and even though *.localhost all resolve to 127.0.0.1, nginx will pluck out the correct configuration and proxy_pass the correct one.
That's because there defines in etc services (really the place where etc services gets its mapping). You're putting the cart in front of the horse