Apache 2 stops serving on port 80 if SSLEngine active

-1

I wanted to add SSL to my server (OpenSuse 13.2, Apache2, single domain, no virtual domains) and after I configured it to work I discovered that when I set

SSLEngine on

the Apache2 stops serving on port 80 but serves on 443

I'm puzzled as I do not find anyone else to have this problem (Or it could be so simple and I can not see it....)

------------------Edit---------------------

In the end I want HTTP to work on port 80 and HTTPS on port 443

Alex

Posted 2015-02-06T12:20:51.090

Reputation: 115

1It the Listen directive set in the config? – chaos – 2015-02-06T12:32:04.673

Yes, both Listen 80 and Listen 443 are present in listen.conf – Alex – 2015-02-06T13:50:55.973

Remove 443 in the config, and try again – chaos – 2015-02-06T13:59:14.207

Removing 443 makes even the HTTPS requests to fail which is what I expected... – Alex – 2015-02-06T14:04:05.707

Yes because the browser tries to connect to port 443, which nothing listens on. The correct url must be https://server:80 – chaos – 2015-02-06T14:05:50.470

To my surprise when I commented out Listen 443 any request to http : / / myserver:80 worked...so what's next? – Alex – 2015-02-06T14:09:04.377

I don't know whats next. What do you want to achieve? Port 443 was the correct one for http with ssl. Now you have ssl at port 80. – chaos – 2015-02-06T14:11:12.347

No, I want HTTP to work on 80 and HTTPS on 443 - the normal way :) – Alex – 2015-02-06T14:13:33.173

You should include that in your question – chaos – 2015-02-06T14:21:27.603

Answers

1

To set apache to serve http on port 80 AND https on port 443 you have to create 2 virtual hosts:

<VirtualHost *:80>
    ServerName your-domain.com
    DocumentRoot /var/www/
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /var/www/
    ServerName your-domain.com
    SSLEngine On
    SSLCertificateFile /path/to/server.crt
    SSLCertificateKeyFile /path/to/server.key
    #Other SSL options
</VirtualHost>

chaos

Posted 2015-02-06T12:20:51.090

Reputation: 3 704

It's a single domain and I do not plan to add more domains for that server....so I'm not sure virtual host option is needed.... – Alex – 2015-02-06T14:24:38.527

It is, just add the same domain in both directives. You have to configure both. If the sever is accesses via port 80 the upper is active, with port 443 the lower one. – chaos – 2015-02-06T14:27:02.533

It seems you were right, you need to have 2 virtual hosts...one for port 80 and one for port 443. I knew how to do that but I never knew there is that is the only way. Thanks – Alex – 2015-02-09T13:34:20.843