subdomain point to different port

panosru

Verified User
Joined
Oct 8, 2006
Messages
80
Location
Greece
Hello, is it possible to have a subdomain point instead of port 80 to another port where node.js server is running?

I tried in custom httpd configurations to set the following:

Code:
|*if SUB="foo"|
|?PORT_80=3000|
|*endif|
but it seems is not working because when I access for example foo.bar.com I don't get what I expected to get but when I access foo.bar.com:3000 I get what I expected.

Thanks
 

Arieh

Verified User
Joined
May 27, 2008
Messages
1,208
Location
The Netherlands
I once used the APE Project, I think its similar to node.js.

I indeed used mod_proxy

as custom httpd config I had:

Code:
ProxyRequests Off
RewriteEngine   on
ProxyPreserveHost on

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

RewriteCond  %{HTTP_HOST}     ^(.+)$
RewriteRule  /(.*)  http://%1:3000/$1 [P]
you might not need the rewrite condition and rule as I had to deal with a wildcard subdomain. You could use the normal ProxyPass/ProxyPassReverse, but it this should also work.

Also remember that the original IP address of the client is then put in the X-Forwarded-For header. I took the liberty to quickly google the solution for nodejs; http://forum.webfaction.com/viewtopic.php?pid=16862#p16862
 
Top