i want to setup a virtual host to the url of with some port

e.g. my server name is rockstar.net

so i want to setup a subdomain on my server.where i should access the content of http://rockstart.net:8001/

what i tried :

<VirtualHost *>
  ServerName content.rockstart.net
  DocumentRoot "http://rockstart.net:8001/"

</VirtualHost>

which is giving error

Warning: DocumentRoot [/etc/apache2/http:/rockstar.net:8001/] does not exist
link|improve this question

50% accept rate
feedback

2 Answers

The DocumentRoot points to the folder in the local folder structure where the site is hosted, e.g. (on a linux system) /var/www/html/rockstart.net. The port number must be included in the VirtualHost definition. Therefore your VHost definition should rather look like:

<VirtualHost *:8001>
  ServerName content.rockstart.net
  DocumentRoot "/var/www/html/rockstart.net"

</VirtualHost>

However, this will still require the users to enter http://rockstart.net:8001 into their browser. I suspect what you had in mind was actually more like a redirection. If the redirection needs to include a change of port (i.e. from 8001 to 80) then you either need to use a reverse proxy or a DNAT firewall.

Or, if the content that is to be made available under http://content.rockstart.net is located on the same server where rockstart.net is located, you could simply use a

<Location> 

redirection within the file system. However, in that case I wonder why you don't just point content.rockstart.net at the same location where rockstart.net:8001 gets its content from?

link|improve this answer
<VirtualHost *:8001> ServerName content.rockstart.net DocumentRoot "/var/www/html/rockstart.net" </VirtualHost> is not working how to use location tag ? – Rahul Mehta May 17 '11 at 12:33
Well, where is the relevant content located, i.e. what is the DocumentRoot for the VHost running rockstart.net:8001? For the explanation on how to use the <Location> directive, read the Apache manual (I presume this is what you are using). – wolfgangsz May 17 '11 at 12:42
the content of rockstart.net:8001 is coming from node.js server – Rahul Mehta May 17 '11 at 12:44
@Rahul Are you setting up a production server? – i.amniels May 17 '11 at 13:11
I am sorry, @Rahul, but your last comment doesn't make any sense to me whatsoever. Is the content on the same machine or not? And if yes, what is its location? – wolfgangsz May 17 '11 at 13:33
show 2 more comments
feedback

The DocumentRoot directives describes the physical path on the machine, like /var/www/myvhost.net.

Set this directive as a path and use ServerName for the first and ServerAlias for every other name you want to point to your files, defined in DocumentRoot.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.