Prevent Apache Virtual Hosts to respond to all ports
<p>I am on a bit of a struggle here because of something that should be really simple to do but i cant seem to figure it out...</p>

<p>I want to have two different virtual hosts defined, for two different ports. So foo.com:81, and bar:82 serve different contents.
The problem is that if i access foo:82 Apache serves me the contents of bar:82.
What configuration is needed to foo only listens from port 81 and bar only listens to port 82?</p>

<p>/etc/apache2/sites-enabled/test1.conf</p>

<pre><code>NameVirtualHost *:81
&lt;VirtualHost *:81&gt;
        ServerName test1
        ServerAlias test1

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html1
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
&lt;/VirtualHost&gt;
</code></pre>

<p>/etc/apache2/sites-enabled/test2.conf</p>

<pre><code>NameVirtualHost *:82
&lt;VirtualHost *:82&gt;
        ServerName test2
        ServerAlias test2

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html2
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
&lt;/VirtualHost&gt;
</code></pre>

<p>/etc/apache2/ports.conf</p>

<pre><code>Listen 80
Listen 81
Listen 82

&lt;IfModule ssl_module&gt;
        Listen 443
        listen 444
&lt;/IfModule&gt;

&lt;IfModule mod_gnutls.c&gt;
        Listen 443
        listen 444
&lt;/IfModule&gt;
</code></pre>

<p>/etc/hosts</p>

<pre><code>127.0.0.1  test1
127.0.0.1  test2
</code></pre>

<p>Thank you for you time...</p>