Apache to listen to multiple ports

apache-2.2

I have achieved setting up multiple virtual NIC in 1 VM, and bind websites to different IP on 1 server, e.g., access 2 websites by:

http://10.188.2.150
http://10.188.2.152    <--both IPs belong to the same server

The drawback is that in virutalbox, 1 VM can have 4 network card maximum.

Then, I am trying out the following: get 2 websites bind to the same IP address but different ports, so that I can access the 2 websites like this:

http://10.188.2.150:8003
http://10.188.2.150:8004

(I have checked that these 2 ports are not in use by 'lsof -i :[port]')

But I cannot access the website by opening, e.g. : http://10.188.2.150:8003

I set up my httpd.conf like this:

Listen 10.188.2.150:8003
Listen 10.188.2.152:8004

<VirtualHost 10.188.2.150:8003>
ServerName 10.188.2.150:8002
ServerAdmin admin@localhost
DocumentRoot /var/www/html/panda-web/html
<Directory /var/www/html/panda-web/html>
  AllowOverride All
</Directory>
RewriteEngine On
RewriteOptions Inherit
</VirtualHost>

<VirtualHost 10.188.2.150:8004>
ServerName 10.188.2.150:8004
ServerAdmin admin@localhost
DocumentRoot /var/www/html/sheep-web/html
<Directory /var/www/html/sheep-web/html>
  AllowOverride All
</Directory>
RewriteEngine On
RewriteOptions Inherit
</VirtualHost>

I've looked apache website but I must have missed something? Has anyone tried this?

Best Answer

But I cannot access the website by opening

Not a very meaningful analysis of the problem.

  • Have you checked if the webserver has the port open and is indeed listening for connection (using, e.g. netstat - BTW you forgot to mention what OS this is running on)?
  • Have you ried sniffing the packets going back and forth (e.g. using wireshark)?
  • Have you looked at your server logs?
Related Topic