Reputation: 331
Okay, I'm at a certain point where I feel a huge amount of stupidity on myself because of reading hundreds of manual and instruction pages and still not getting it. I hope you can help me!
I have a server running Ubuntu Server. On the server I'm running ddclient for updating my IP with dyn.com. There I have a domain "rasterkomplex.net" which points to the updated IP. Easy.
There is also a camera connected to the server which runs it's own webserver @ port 3360.
When I'm now entering: rasterkomplex.net:3360 - voilà. But now comes 2 minecraft server running simultaneously on 5001 and 5002. For every mc-server, there's the dynmap-plugins which runs also a webserver on different port. And then a webstorage on... you get it? I don't want to remember like 8 or more ports, just for accessing the related service.
What I want to accomplish:
cam.rasterwerks.net -> internal to 127.0.0.1:3360
mc1.rasterwerks.net -> internal to 127.0.0.1:5001
mc2.rasterwerks.net -> internal to 127.0.0.2:5002
etc. etc. etc.
I read a lot about VHosts, ProxyPass etc. But I'm not able to manage it getting work.
Can you give me a direction how to accomplish this? If it has to do with VHosts, maybe a sample?
Thank you very very much for your time!
Regards,
Elias.
Upvotes: 1
Views: 4970
Reputation: 30207
You can do it with apache
on one hand with ProxyPass
of mod_proxy
redirecting you here or there, or, what you also can do is install haproxy
. Then, based on the Host in the URL that's being requested pass the request to one or another web storage.
An example config of haproxy
doing exactly that would be:
frontend public
bind X.X.X.X:80
mode http
log global
option httplog
option dontlognull
option httpclose
maxconn 8000
clitimeout 90000
reqisetbe ^Host:\ .*hudson hudson
backend hudson
mode http
balance roundrobin
contimeout 120000
srvtimeout 120000
redispatch
retries 5
server internal.host.com Y.Y.Y.Y:8080 check inter 1000
So in this example, haproxy
is bound to port 80 and when URL that's requested contains *.hudson
, it gets redirected to an internal.host.com
with IP of Y.Y.Y.Y
to port 8080
.
Now, for the apache
based solution.
You can define multiple VHosts, with different names, each of them containing the following.
To do name-based vhosting, your apache config should contain:
NameVirtualHost *
Then, the vhost itself, should be:
<Virtualhost *>
DocumentRoot "/var/www/somewhere"
ServerName localhost
ServerAdmin [email protected]
DirectoryIndex index.html index.php
ProxyRequests On
ProxyPreserveHost On
ProxyVia full
<proxy>
Order deny,allow
Allow from all
</proxy>
ProxyPass / http://somehost:1234/
ProxyPassReverse / http://somehost:1234/
</Virtualhost>
Feel free to choose whatever solution seems more viable to you.
Upvotes: 1