Monday, September 10, 2018

Trouble starting apache with two virtual hosts, 2 ip's and 2 ssl's

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


ServerAdmin me@site1.com
ServerName site1.com
ServerAlias www.site1.com

RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule (.*) https://www.site1.com/ [R]



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




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


ServerAdmin me@site2.com
ServerName site2.com

ServerAlias www.site2.com
RewriteEngine On
RewriteCond %{SERVER_PORT} !4430
RewriteRule (.*) https://www.site2.com/ [R]



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




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)

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...