←back to thread

I can see your local web servers

(http.jameshfisher.com)
652 points jamesfisher | 6 comments | | HN request time: 1.586s | source | bottom
1. jasonkester ◴[] No.20029053[source]
I only ever run my local dev server on port 80, and use a hosts file to assign custom (fake) domain names to each of the sites I want to run.

I mentioned as much here a few years ago when I first came across this idea of assigning (and remembering) random unique port numbers to every one of your apps in development, and was surprised to hear that it's such a common practice. It seems sub-optimal for a lot of reasons, beyond the obvious one noted in the article.

The big one for me is that none of my apps need to know anything about how to handle port numbers URLs. They know their own domain name via a config setting that can be flipped on the live server. It's the same pattern (with no colons or numbers to worry about) so there are no edge cases to test.

replies(2): >>20029263 #>>20033617 #
2. ryanjshaw ◴[] No.20029263[source]
Unless I'm missing something, this only works if you are running one site at a time, or you have a single web server bound to port 80 that supports virtual hosts. You also need application and/or configuration support to get this working properly. And even then, if you run any software with an embedded web server you are usually out of luck unless you want to fiddle with a reverse proxy configuration.

For these reasons I, at least, simply run applications on different ports. The problem isn't the port, it's the web browser allowing cross domain requests to local networks by default (another reply here suggested it is WebRTC specifically that is flawed).

replies(2): >>20029592 #>>20030542 #
3. markstos ◴[] No.20029592[source]
For a professional web developer, setting up an Nginx reverse proxy for a few apps should be reasonably efficient. Chances are that most are all of them are written in the same language and configuration can be copy/pasted between them. Or a subdomain pattern can be mapped into a directory pattern, so there is really only one configuration-- Just add a new directory and a matching subdomain starts working, assuming the right wildcard DNS entry is pointed to your localhost.
4. jasonkester ◴[] No.20030542[source]
IIS handles all this out of the box for me. I just bind the host name to the site in question. It sounds like maybe this isn’t something that other web servers do, which is surprising. The whole point of the operation is to seamlessly run 30 odd websites on one dev machine without needing to fiddle with port numbers or anything else.
replies(1): >>20049575 #
5. Cyberdog ◴[] No.20033617[source]
This is more or less what I do, except instead of 80, I use a port above 1024 because those don't require root privileges to bind to: https://www.w3.org/Daemon/User/Installation/PrivilegedPorts....

I'm sure the Container Culture Kids have their own overly-complicated thing, though.

6. londons_explore ◴[] No.20049575{3}[source]
In the *nix world and with the move to containerization, most applications now assume they are the only thing running on the web server, and therefore demand custom config/settings. Node apps for example are their own server.