Forwarding through Apache

g8m3rtag

10-08-2008 05:34:10

I have a dynamicdns (I believe that's what its called) service setup through no-ip.com. That way if I am away from my home I can type in x.myfreedomain.org and it will forward the request to my external IP at my house (Its dynamic and so it changes and I don't want to not have a clue what it is when im 500 miles away). I successfully setup a page with Apache to just require a login and show an Index of page. I also have VibeStreamer setup and it uses the default port 8081. This way I can just go to x.myfreedomain.org8081, login to VibeStreamer and have access to my music. Recently though, I was at a location that blocks port 8081.

I tried disabling Apache, as it is using port 80 so that there would be no conflicts. and trying to bind port 80 to the VibeStreamer machine, and it will not bind.

So I am wondering if there is a way I can forward from the Apache machine (lets say 192.168.1.100) to the VibeStreamer machine (192.168.1.105), that way when I try to access VibeStreamer, all the traffic goes through port 80 (running through the apache machine) that way if I am at a location blocking port 8081 I can still access my music.

flux

10-08-2008 15:58:59

Take a look at the apache directive ProxyPass. I'm having some trouble with this myself right now, and so cannot post a complete config. I use this functions a lot on other applications and I have also had it working with Vibe Streamer, when i hosted it on a separate sub-domain.
Earlier sollution, which works
vibe.domain.com -> ProxyPassed to internal address -> http//192.168.0.108081
Session cookies gets the vibe.domain.com (relative /)
My current problem
www.domain.com/vibe -> ProxyPassed to internal address -> http//192.168.0.108081
Some confusion arises about the cookies and vibe complains. (

But if you register another dynamic host for your vibe it is possible to get this working... But subdomains and https, which I want to use, doesn't work so well... Leaving me with few options...

Also note that I have done this only on Linux, but have had friends set this up successfully.

hypnotoad

11-08-2008 23:04:46

I posted a solution for this that worked great for me here [urlo4ydxte0]http://www.vibestreamer.com/forum/viewtopic.php?t=387&highlight=apache[/urlo4ydxte0]. It touches basically the same problem, so it should work for you too.

flux

14-08-2008 10:36:55

The sollution hypnotoad posted is the one I used before. And it works great!

But...
The problems arise (my current problems) when one wants to use https on the apache-server on the standard port (443) while still having access to the Vibe Stream-server. Yes, you can use different virtual hosts and it works... nearly. Except from that since you can only have one certificate shared by all virtual hosts, the certificate with www.domain.com gets invalid for vibe.domain.com and clients haveto discard the invalid certificate in their browsers.

The sollution would be having vibe below www.domain.com/<prefix>/ and proxypassed from there. Ex www.domain.com/vibe/. Leaving all other locations to the webserver. Still passing www.domain.com/forum and other urls to their ordinary places.

As far as I have come is with the prefix (my case /v) and also rewriting the /ajax /share and other prefixes to corresponding /v/ajax, /v/share and such...

Some problems i have encountered
- Session cannot be loaded (due to following problems).
- Ajax calls doesn't get rewritten with the prefix (workaround is rewrite of /ajax to /v/ajax).
- Ajax responses gets wrapped in html (proxyhtml filter problem).

Problems still left
- Flashplayer cannot start songs (Failed to load song...) when the filepath contains a + char (plus). Everywhere else it gets urlencoded before passed. I don't know where this request gets rewritten. It seems to me to be the request from the flashplayer that is wrongfully rewritten in apache.

My current apacheconfig (with ugly workarounds) also available at https//www.sys.nu/linux/vibestreamer/mods

[code1j039pd6]
<VirtualHost *:443>
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLCertificateKeyFile /etc/apache2/ssl/apache.pem

ServerAdmin webmaster@sys.nu

# REWRITES

RewriteEngine On
RewriteCond %{REQUEST_URI} /v/
RewriteRule /v/(.*) http://172.16.1.21:8081/$1 [P,L]

RewriteCond %{REQUEST_URI} /auth/
RewriteRule /(.*) http://172.16.1.21:8081/$1 [P,L]

RewriteCond %{REQUEST_URI} /share/
RewriteRule /(.*) http://172.16.1.21:8081/$1 [P,L]

# PROXY PASSES
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPreserveHost On


# RewriteLog "/tmp/rewrites.log"
# RewriteLogLevel 3

<Directory proxy:*>
order allow,deny
allow from all
</Directory>

<Location /v/>
ProxyPassReverse /
ProxyHTMLExtended on
ProxyHTMLURLMap / /v/ cei
ProxyHTMLURLMap ajax v/ajax
ProxyHTMLURLMap share v/share
ProxyHTMLURLMap addons v/addons
ProxyHTMLURLMap auth v/auth
</Location>
</IfModule>
[/code1j039pd6]

flux

11-10-2009 09:50:59

I just wanted to add to this topic this
With Vibestreamer 3 and the <path>vibe</path> option in sites.xml, all my problems with forwarding thru an apache web-server, went away.

With that there's no need for any complex rewrites and such. Only a basic ProxyPass and ProxyPassReverse ... You need to watch the appending slashes (/) though. Or you might get redirect loops.

Post or message me if you want more details.

Thank's siit for making it work!

flux

19-11-2009 07:54:46

Upon request I have posted my related configuration files (ripped out some other stuff).

Please post if you succeed or if you get problems. This should be enough to get it running though.

[b2zo7y8i3]on apache webserver[/b2zo7y8i3]
/etc/apache2/sites-enabled/SSL-default
[code2zo7y8i3]
<VirtualHost *:443>
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLCertificateKeyFile /etc/apache2/ssl/apache.pem
ServerAdmin webmaster@domain.top
RewriteEngine on

<IfModule mod_proxy.c>
<Directory proxy:*>
order allow,deny
allow from all
</Directory>

<location /vibe>
proxypass http://172.16.30.21:8081/vibestreamer
proxypassreverse http://172.16.30.21:8081/vibestreamer
</location>

</IfModule>
# ... other locations/directories etc. ripped out...
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
[/code2zo7y8i3]

[b2zo7y8i3]on server w ip 172.16.30.21[/b2zo7y8i3]
...\Vibe Streamer\conf\sites.xml
[code2zo7y8i3]
<sites>
<site>
<name>Default Site</name>
<root>sites/default</root>
<path></path>
<anonymousAccess>false</anonymousAccess>
<anonymousUserGuid></anonymousUserGuid>
<authForm>/login.vibe</authForm>
<authRealm>My Personal Vibe Server</authRealm>
<authType>form</authType>
<permissions>
<permission>
<userGuid></userGuid>
<groupGuid></groupGuid>
<remoteAddress></remoteAddress>
<allowed>true</allowed>
</permission>
</permissions>
</site>
<site>
<name>External Site</name>
<root>sites/default</root>
<path>/vibestreamer</path>
<anonymousAccess>false</anonymousAccess>
<anonymousUserGuid></anonymousUserGuid>
<authForm>/login.vibe</authForm>
<authRealm>My Personal Vibe Server</authRealm>
<authType>form</authType>
<permissions>
<permission>
<userGuid></userGuid>
<groupGuid></groupGuid>
<remoteAddress></remoteAddress>
<allowed>true</allowed>
</permission>
</permissions>
</site>
</sites>
[/code2zo7y8i3]

sean.dexter

20-11-2009 16:33:27

Hello flux,

great work! It works absolutely smooth 8)

Since I do not care for SSL encryption I don't know if that works, too roll

Thanks again!

Best regards,
Sean. mrgreen

CraigLason

14-12-2010 13:13:43

If you're going to use a proxy then it needs to be a good one for this to work. Finding them is very hard though.


reverse phone detective[/url3kx5zjg5] | [url=http://honestreview4u.com/fat-burning-furnace3kx5zjg5]fat burning furnace[/url3kx5zjg5]

Silver45

21-01-2011 03:03:15

Great work!!
Thanks for sharing!!!

randy112

28-09-2012 14:58:02

The best thing is not to find proxies but purchase them. Or you can go the hardware route, which is even costlier, but more efficient.

Thanks, excellent information.