You are not logged in.
Hi all,
I'm running an Arch VPS, and I'd like to run multiple web services on it, each reachable through port 80 from a different domain-name. This would help me set up small experimental web-services without the need for additional IP-addresses. But I'm not sure how to accomplish this yet. I think I need to do something like this:
Set up each service from a different user, each listening to a different port (e.g., 10080, 20080, 30080, …)
Run a root process that listens to port 80 and redirects traffic to those ports based on the requested domain-name.
I'd like to know the easiest and most efficient way to set up this routing process. I'm sure I could rig something up, but I'm equally sure there must be a standard solution and a set of best practices. My Google-fu fails me.
Thanks in advance!
Last edited by mhelvens (2013-12-23 22:04:09)
Offline
What you're talking about is called Virtual Hosts. There are thousands of tutorials available to achieve this, including our own wiki: https://wiki.archlinux.org/index.php/LAMP#Virtual_Hosts
EDIT: And planning to run the HTTP daemon as root is defintely unnecessary
Last edited by fukawi2 (2013-12-22 22:07:27)
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
What you're talking about is called Virtual Hosts.
Great! That's the search term I was looking for. :-)
EDIT: And planning to run the HTTP daemon as root is defintely unnecessary
I was under the impression that only root could listen on ports below 1024. What is the proper way to get around this? I would indeed prefer not to use root. :-)
Thanks!
Offline
I was under the impression that only root could listen on ports below 1024. What is the proper way to get around this? I would indeed prefer not to use root. :-)
One way is for the server to starts as root, open the port and drop privileges. The alternative is to setcap CAP_NET_BIND_SERVICE for your server binary.
apache should be configured to drop capabilities by default. I believe nginx and lighttpd do the same.
PS: nginx calls vhosts "Server Blocks" and not Virtual Hosts like apache, lighttpd simply has "Conditionals" you can use for any sort of settings.
PPS: If you need to forward the request to a server on another port, apache has mod_proxy. You might be able to use fcgi, too.
Last edited by progandy (2013-12-22 22:39:06)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
A quick Google search tells me CAP_NET_BIND_SERVICE doesn't work for individual scripts; just for binaries. All my web-apps (so far) are Node apps, and setcapping the node binary seems wrong.
I just realized I could use iptables to redirect port 80 to some higher port, then do the host-based routing from that other port. Any reason that's a bad idea (other than the latency created from two redirections)?
Last edited by mhelvens (2013-12-22 23:13:23)
Offline
You could do that. If you want to run everything in node.js, then use bouncy to redirect to other ports.
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
You could do that. If you want to run everything in node.js, then use bouncy to redirect to other ports.
I indeed ended up going that way. It's working well. Thanks all!
Offline