←back to thread

I can see your local web servers

(http.jameshfisher.com)
652 points jamesfisher | 1 comments | | HN request time: 0.618s | source
Show context
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 #
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 #
1. 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.