You are not logged in.
Hi all,
I would like to access web services running on my localhost with hostname/domain name instead of IP:Port. I mean this kind of mapping:
127.0.0.1:8081 -> mysite1.local
127.0.0.1:8082 -> mysite2.local
etc.
Any idea how can it be done?
I can access some machines in my LAN this way after I've configured the DNS Resolver settings in my pfSense router, but I don't know how can I do something similar on my localhost. I've tried once in the past with dnsmasq, but I couldn't configured it correctly and had issues.
Last edited by karcher (2020-05-28 14:42:59)
Offline
man hosts
EDIT: wait, you want names for ports? Nevermind, I'm not sure there is any practical way to do that. You can easily have various names for static IP addresses, but domain names refer to domains, not ports. You could run nginx or another reverse proxy to forward each domain name to the right port. If you really do need the ports to be determined by the name, then this is what I'd do.
Last edited by Trilby (2020-05-28 12:37:08)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks for the response!
you want names for ports?
So to say.
You could run nginx or another reverse proxy to forward each domain name to the right port.
Hmm. I know that a reverse proxy can be used in front of web servers. Is it normal to use it also for desktop computers?
Offline
In a pinch, browser bookmarks do a fair job.
Offline
@Zod: We don't know any application details. Bookmarks are fine for storing the URI for the client (web browser), but are useless if you want to make Ajax calls to those "domains".
Some more background from the OP might clear up what intention is behind that setup to deliver a more targeted answer.
But so far, a proxy seems like a good idea. If the amount of separated local web services is high enough, OP might also want to consider using Unix Domain Sockets.
Last edited by schard (2020-05-28 13:29:22)
Inofficial first vice president of the Rust Evangelism Strike Force
Offline
Some more background from the OP might clear up what intention is behind that setup to deliver a more targeted answer.
Right. I need this setup for Web Development, mapping sites/apps to names instead of ports.
E.g.:
http://mysite.local
or
http://mysite.local.dev
instead of:
http://localhost:3000
Last edited by karcher (2020-05-28 13:45:46)
Offline
Run nginx or lighttpd as a service on port 80. Create proxy rules in the appropriate configuration files to rewrite the URLs and forward them to your software that is on ports 8081 and 8082
Squid might technically be the better choice, but its caching (which is what it does) might cause confusion as you change the backend service.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
OK. Many thanks to all!
Offline