0

Right now I'm doing this with the following Apache directives to map host names to port numbers:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName local.stardust-game.com
    ProxyPass / http://127.0.0.1:5555/ retry=0
</VirtualHost>

<VirtualHost *:80>
    ServerName local.wdi-toolbelt.com
    ProxyPass / http://127.0.0.1:9992/ retry=0
</VirtualHost>

(On my development machine, the local.* domains are set to 127.0.0.1 in my hosts file.)

I'm just looking for a convenient way to run multiple apps of arbitrary origin (some are Ruby, some are Python, etc.) that are accessed through port 80 but by different hostnames.

Apache seems like overkill, and I want to check my gut feeling that there's a much simpler way to do this.

I'm guessing that the solution must involve checking the Host header of all incoming requests, since without that there is no way to know what process the request is intended for, but again, it feels like overkill to have Apache running just to perform this request forwarding. I'm literally not using it for anything else--just proxying requests to different processes running on the same machine.

  • Is nginx a more lightweight, or perhaps easier-to-configure solution?
  • For development purposes, is there a compelling reason not to write a small C/Ruby/Python script that does this? (I'm thinking that something like this already exists and I just don't know what it's called. "Virtual proxy host multiplexing"?)
  • Would such a script be stupid to use in staging/production?
  • Is there a way to do this or something similar to it without needing to check the Host header?
Max Cantor
  • 121
  • 3

1 Answers1

0

If you are using this for testing on a local network with low traffic levels, you don't have a lot to gain by setting up nginx, even though nginx is more efficient than Apache.

If you use Apache, you probably will need to add a ProxyPassReverse directive.

https://stackoverflow.com/questions/8137861/do-i-need-to-use-proxypassreverse-if-im-using-mod-rewrite

In your shoes, I would not spend too much time on the proxy. You may be over optimizing and your time could be better spent on developing your application. Apache is a perfectly acceptable solution, but you could look at nginx or a dedicated proxy such as pound.

http://www.unixmen.com/pen-a-pound-2-great-opensource-server-load-balancing-tools-for-linux/

https://calomel.org/pound.html

John Auld
  • 594
  • 2
  • 6