0

I have been reading through all the discussions on the subject and decided to use the Redirect method in the httpd.conf file with no luck... So I came back here to this knowledgable crowd.

We have a service let's call it "host1" (https based) that runs on a Centos 6.x We decided to add our website there as well to leverage a purchased wildcard SSL certificates that is nicely working for the two SSL accesses when connecting in https.

Unfortunately our website is not accessible and times-out when a user is typing ourdomain.com, www.ourdomain.com, or uses http for ourdomain.com or www.ourdomain.com. Everything works fine with https for ourdomain.com, www.ourdomain.com and host1.ourdomain.com.

Below you will find the httpd.conf and ssl.conf truncated to the Virtual Hosts areas in both and hiding our specific details.

I get the following error from httpd with this configuration:

This one is not happening anymore, thanks for the hints Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80

------------ Start httpd.conf ------------------
# >>httpd configuration truncated down to Virtual Hosts

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

 <VirtualHost *:80>
   ServerName www.ourdomain.com
   Redirect permanent / https://www.ourdomain.com/
 </VirtualHost>

------------ End httpd.conf ------------------

------------ Start ssl.conf to manage 443 and ssl certificates------------------

# >>SSL Configuration Truncated up to Listen 443 and Virtual Hosts

Listen 443

    #Listen for virtual host requests on all IP addresses
NameVirtualHost *:443

# >>SSL Config ...

##
## SSL Virtual Host Context
##

<VirtualHost *:443>

DocumentRoot /var/www/html/dir1
ServerName host1.ourdomain.com
ServerAlias host1.ourdomain.com

ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn

SSLEngine on

# >>SSL Certificates Config ... Truncated
</VirtualHost>


<VirtualHost *:443>

DocumentRoot /var/www/html/dir2
ServerName ourdomain.com
ServerAlias ourdomain.com www.ourdomain.com

ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn

SSLEngine on

# >>SSL Certificates Config ... Truncated

</VirtualHost>

------------ End ssl.conf ------------------

Where is the issue?? I would not want to settle with .htaccess as I want to avoid having AllowOverride All impacting our host1 service.

Thanks.

Oly

----- Added section for netstat 2nd request by ngn

# netstat -ant | grep 80
tcp        0      0 :::80                       :::*                        LISTEN

----- Added section for lsof request by Hbruijn - any idea?

# lsof -iTCP:80
COMMAND   PID   USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
httpd   24331   root    5u  IPv6 5381394      0t0  TCP *:http (LISTEN)
httpd   24334 apache    5u  IPv6 5381394      0t0  TCP *:http (LISTEN)
httpd   24335 apache    5u  IPv6 5381394      0t0  TCP *:http (LISTEN)
httpd   24336 apache    5u  IPv6 5381394      0t0  TCP *:http (LISTEN)
httpd   24337 apache    5u  IPv6 5381394      0t0  TCP *:http (LISTEN)
httpd   24338 apache    5u  IPv6 5381394      0t0  TCP *:http (LISTEN)
httpd   24339 apache    5u  IPv6 5381394      0t0  TCP *:http (LISTEN)
httpd   24340 apache    5u  IPv6 5381394      0t0  TCP *:http (LISTEN)
httpd   24341 apache    5u  IPv6 5381394      0t0  TCP *:http (LISTEN)
httpd   25323 apache    5u  IPv6 5381394      0t0  TCP *:http (LISTEN)
httpd   25325 apache    5u  IPv6 5381394      0t0  TCP *:http (LISTEN)
httpd   25326 apache    5u  IPv6 5381394      0t0  TCP *:http (LISTEN)

New addition to this issue

Here are the httpd -S results, all seem ok from httpd standpoint. But connecting to 'http : //ourdomain.com' or 'http : //www.ourdomain.com' stalls in all browsers... Rewrite with https is not working at all.

wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
     default server ourdomain.com (/etc/httpd/conf/httpd.conf:1032)
     port 80 namevhost ourdomain.com (/etc/httpd/conf/httpd.conf:1032)
             alias ourdomain.com
             wild alias *.ourdomain.com
*:443                  is a NameVirtualHost
     default server host1.ourdomain.com (/etc/httpd/conf.d/ssl.conf:40)
     port 443 namevhost host1.ourdomain.com (/etc/httpd/conf.d/ssl.conf:40)
             alias host1.ourdomain.com
     port 443 namevhost ourdomain.com (/etc/httpd/conf.d/ssl.conf:95)
             alias ourdomain.com
             alias www.ourdomain.com
Syntax OK

httpd.conf for port 80

<VirtualHost *:80>
    ServerName ourdomain.com
    ServerAlias ourdomain.com *.ourdomain.com
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
</VirtualHost>
oly
  • 1
  • 2
  • Looks like there is something already bound to port 80. Can you do a `netstat -n | grep 80` and check what process is using the port? – ngn Jul 22 '15 at 14:53
  • The error message `Address already in use: make_sock: could not bind to address [::]:80` indicates that something else is already listening to port 80 check for instance with `sudo lsof -iTCP:80` – HBruijn Jul 22 '15 at 14:57
  • Thanks ngn, HBruijn, I have updated my post with results along your requests... Not really clear what is using port 80?! – oly Jul 22 '15 at 16:17
  • Sorry, can you replace that with the output for netstat -ant | grep 80? – ngn Jul 23 '15 at 13:38

1 Answers1

0

For the first problem, try setting your ServerAlias variable to include the following on all virtual host sections.

ServerAlias ourdomain.com *.ourdomain.com

Ref: http://httpd.apache.org/docs/2.4/mod/core.html#serveralias

As per startup error, it appears that a previous run is not shutdown properly i.e. your netstat & lsof output shows that it is still running and listening on port 80. Before you attempt to start again, make sure httpd is not running already i.e. you should not see any output for httpd when you run lsof -iTCP:80

Arul Selvan
  • 1,428
  • 13
  • 11