2

In Apache 2.2.22 I am attempting to run two virtual hosts with two IP addys and two SSL certs. I have nothing regarding listening to ports or NameVirtualHost in any other configuration files other than the files that configure the virtual hosts. In the process of getting this to work I would like to have the minimum amount of code necessary.

In the sites-available directory I have site1.com config file:

NameVirtualHost 1.1.1.1:80
Listen 1.1.1.1:80
Listen 1.1.1.1:443

<VirtualHost 1.1.1.1:80>
    ServerAdmin me@site1.com
    ServerName site1.com
    ServerAlias www.site1.com
    RewriteEngine On
    RewriteCond %{SERVER_PORT} !443
    RewriteRule (.*) https://www.site1.com/ [R]
</VirtualHost>

<VirtualHost 1.1.1.1:443>
    ServerName site1.com
    ServerAlias www.site1.com
    DocumentRoot /home/j/site1/public

    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/site1.com.crt
    SSLCertificateKeyFile /etc/apache2/ssl/site1.com.key
    SSLCertificateChainFile /etc/apache2/ssl/gd_bundle_site1.crt

    LogLevel warn
    ErrorLog /home/j/site1/log/error.log
    CustomLog /home/j/site1/log/access.log combined
</VirtualHost>

If site1.com is the only site that is enabled, the server starts fine. When I enable site2.com I run into trouble. Sudo apachectl configtest results in Syntax OK but a restart of apache results in (99)Cannot assign requested address: make_sock: could not bind to address 2.2.2.2:8080 no listening sockets available, shutting down Unable to open logs Action 'start' failed. Here's the content of site2.com:

NameVirtualHost 2.2.2.2:8080
Listen 2.2.2.2:8080
Listen 2.2.2.2:4430

<VirtualHost 2.2.2.2:8080>
    ServerAdmin me@site2.com
    ServerName  site2.com
    ServerAlias www.site2.com
    RewriteEngine On
    RewriteCond %{SERVER_PORT} !4430
    RewriteRule (.*) https://www.site2.com/ [R]
</VirtualHost>

<VirtualHost 2.2.2.2:4430>
    ServerName site2.com
    ServerAlias www.site2.com
    DocumentRoot /home/j/site2/public

    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/site2.com.crt
    SSLCertificateKeyFile /etc/apache2/ssl/site2.key
    SSLCertificateChainFile /etc/apache2/ssl/gd_bundle_site2.crt

    LogLevel warn
    ErrorLog /home/j/site2/log/error.log
    CustomLog /home/j/site2/log/access.log combined
</VirtualHost>

Thanks for your help.

UPDATE:

Results for netstat -lpn less udp6:

(No info could be read for "-p": geteuid()=1000 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      -               
tcp        0      0 1.1.1.1:80         0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:7187            0.0.0.0:*               LISTEN      -               
tcp        0      0 1.1.1.1:443        0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:55363         0.0.0.0:*               LISTEN      -               
tcp6       0      0 :::7187                 :::*                    LISTEN      -               
udp        0      0 0.0.0.0:68              0.0.0.0:*                           -               
udp        0      0 1.1.1.1:123        0.0.0.0:*                           -               
udp        0      0 127.0.0.1:123           0.0.0.0:*                           -               
udp        0      0 0.0.0.0:123             0.0.0.0:*                           -               
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name    Path
unix  2      [ ACC ]     STREAM     LISTENING     169974   -                   /tmp/passenger.1.0.32045/generation-0/spawn-server/socket.32055.19978820
unix  2      [ ACC ]     STREAM     LISTENING     2823     -                   @/tmp/fam-root-
unix  2      [ ACC ]     STREAM     LISTENING     180580   -                   /tmp/passenger.1.0.32045/generation-0/backends/ruby.ui0IFvdXouP5Ukb3zZo2fiLBEJOgc5835cbcGK93fhrs5ogoitaPfi1
unix  2      [ ACC ]     STREAM     LISTENING     10547    -                   /var/run/mysqld/mysqld.sock
unix  2      [ ACC ]     STREAM     LISTENING     106      -                   @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     182366   -                   /var/run/apache2/cgisock.32045
unix  2      [ ACC ]     STREAM     LISTENING     395      -                   /var/run/dbus/system_bus_socket
unix  2      [ ACC ]     SEQPACKET  LISTENING     168      -                   /run/udev/control
unix  2      [ ACC ]     STREAM     LISTENING     12724    -                   /var/run/fail2ban/fail2ban.sock
unix  2      [ ACC ]     STREAM     LISTENING     181619   -                   /tmp/passenger.1.0.32045/generation-0/socket
unix  2      [ ACC ]     STREAM     LISTENING     181621   -                   /tmp/passenger.1.0.32045/generation-0/spawn-server/socket.32053.32793072
unix  2      [ ACC ]     STREAM     LISTENING     181640   -                   /tmp/passenger.1.0.32045/generation-0/logging.socket

UPDATE:

grep -r Listen /etc/apache2 produces no reference to Listen on port 8080 other than what is mentioned above.

UPDATE:

Per Jenny D's suggestion below, ifconfig -a produces the following:

dummy0    Link encap:Ethernet  HWaddr be:fc:55:b0:9e:80  
          BROADCAST NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr f2:3c:91:70:34:84  
          inet addr:50.116.59.14  Bcast:50.116.59.255  Mask:255.255.255.0
          inet6 addr: 2600:3c03::f03c:91ff:fe70:3484/64 Scope:Global
          inet6 addr: fe80::f03c:91ff:fe70:3484/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:69078 errors:0 dropped:0 overruns:0 frame:0
          TX packets:41852 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:16773617 (16.7 MB)  TX bytes:69148409 (69.1 MB)
          Interrupt:76 

gre0      Link encap:UNSPEC  HWaddr 00-00-00-00-34-84-00-00-00-00-00-00-00-00-00-00  
          NOARP  MTU:1476  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ip6gre0   Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          NOARP  MTU:1448  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ip6tnl0   Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          NOARP  MTU:1452  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ip_vti0   Link encap:IPIP Tunnel  HWaddr   
          NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:3487 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3487 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:62766 (62.7 KB)  TX bytes:62766 (62.7 KB)

sit0      Link encap:IPv6-in-IPv4  
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

tunl0     Link encap:IPIP Tunnel  HWaddr   
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
  • 1
    I'm assuming the 2.2.2.2 address exists on your system, right? And nothing else is listening on that port? – Nathan C Jul 10 '13 at 17:53
  • 1
    Should <VirtualHost 2.2.2.2:80> be <VirtualHost 2.2.2.2:8080> there? – Etan Reisner Jul 10 '13 at 17:54
  • @EtanReisner Good catch. That might be very well the issue. – Nathan C Jul 10 '13 at 17:56
  • thanks,... that is not the issue tho. typo on my part. see the error msg. +1 for catching it tho. – Jay Jul 10 '13 at 17:57
  • Yeah. I couldn't imagine how that would cause that error message but @NathanC had taken the simple suggestion for that error. =) – Etan Reisner Jul 10 '13 at 17:58
1

This error can be caused by having two Listen directives for the same IP address/port combination.

Since your netstat shows nothing listening on port 8080, I strongly suspect this is your issue.

Try grep -r Listen /etc/apache2 to find them.

  • Already did that. There is no Listen directive for any ip on port 8080 other than what is indicated above. – Jay Jul 10 '13 at 20:35
1

Can't believe it. It was the firewall. Had to add the ports.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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