logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Configuring Apache 2.4 for SSL on Debian 8
Author
20160413



Joined: 13 Apr 2016
Posts: 28

PostPosted: Wed 13 Apr '16 19:02    Post subject: Configuring Apache 2.4 for SSL on Debian 8 Reply with quote

I would like to configure my Apache 2.4 to use two different server certs for two different VirtualHosts on one server with one IP. Unexpectedly this is not easy to configure and I also found no working tut in the web.

This is a disaster since all websites are served by the first VirtualHost on https for http and https after I activate this. I would think that this is an relatively easy thing to configure but reality proves different.

My setup:

ports.conf
Code:
Listen 80

<IfModule ssl_module>
   Listen 443
</IfModule>

<IfModule mod_gnutls.c>
   Listen 443
</IfModule>


default-ssl.conf
Code:
<IfModule mod_ssl.c>
   <VirtualHost *:443>
      ServerAdmin me@example.org

      DocumentRoot /var/www/htdocs

      [...]
   </VirtualHost>
</IfModule>


example.org.conf
Code:

<VirtualHost *:80>
        ServerAdmin me@example.org
        ServerName www.example.org

        RedirectPermanent / https://www.example.org/

   [...]
</VirtualHost>
<IfModule mod_ssl.c>

        SSLStaplingCache shmcb:${APACHE_RUN_DIR}/ssl_stapling(32768)

   <VirtualHost *:443>
      ServerAdmin me@example.org
      ServerName www.example.org
      ServerAlias example.org

      [...]

      SSLEngine on
      
      SSLUseStapling on
      SSLStaplingResponderTimeout 5
      SSLStaplingReturnResponderErrors off

      SSLCertificateFile /etc/ssl/certs/2016.www.example.org.crt
      SSLCertificateKeyFile /etc/ssl/private/2016.www.example.org.key
      SSLCertificateChainFile /etc/ssl/certs/root_bundle.crt

      SSLProtocol all -SSLv2 -SSLv3
      
      SSLHonorCipherOrder on
      SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4"

      [...]
   </VirtualHost>
</IfModule>


alt.example.org.conf
Code:

<VirtualHost *:80>
        ServerAdmin me@example.org
        ServerName alt.example.org

        DocumentRoot /var/www/htdocs/path/to/root/

   [...]
</VirtualHost>
<VirtualHost *:443>
        ServerAdmin me@example.org
        ServerName alt.example.org

        RedirectPermanent / http://alt.example.org/

   [...]
</VirtualHost>


- In case I change <VirtualHost *:443> to <VirtualHost _default_:443> in the "default-ssl.conf" I get the the "SSL_ERROR_RX_RECORD_TOO_LONG" error in the browser.

- If I add NameVirtualHost *:80 and NameVirtualHost *:443 to "ports.conf" to mitigate this as suggested for earlier versions of Apache I get "AH00548: NameVirtualHost has no effect and will be removed in the next release"

- If I have <VirtualHost www.muster.org:443> in my VirtualHosts the first one gets served for all websites on the server e.g. www.example.org for ports 443 and 80.

The following resources led to nothing:
-http://stackoverflow.com/questions/119336/ssl-error-rx-record-too-long-and-apache-ssl
-http://httpd.apache.org/docs/2.4/ssl/ssl_howto.html

I just seem to be incapable of converting the docu into a working environment. Any help appreciated. Thanks for your time.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Mon 18 Apr '16 11:47    Post subject: Reply with quote

In ports.conf there should be only

Code:

Listen 80
Listen 443


Your vhosts should be only with port and not a name in the container ( except for the __default_ vhost)

So only

Code:

<VirtualHost _default_:80>
...

<VirtualHost *:80>
   ServerName muster.org
   ServerAlias www.muster.org
...

<VirtualHost _default_:443>
...

<VirtualHost *:443>
   ServerName muster.org
   ServerAlias www.muster.org
...
Back to top
20160413



Joined: 13 Apr 2016
Posts: 28

PostPosted: Tue 19 Apr '16 22:23    Post subject: Reply with quote

Thank you for your suggestion. I just tried it and I am again running out of luck. Following the suggesting gives me a "Error code: SSL_ERROR_RX_RECORD_TOO_LONG" error.

In other forums the standard reply to this is that I should add NameVirtualHost *:80 and NameVirtualHost *:443 to "ports.conf" to get this working. However this option is no longer available for Apache 2.4

To be able to restart Apache I had to replace <VirtualHost _default_:443> with <VirtualHost *:443> for the default 443 VirtualHost since it is otherwise impossible to start Apache.

Any idea which may help overcome this frustrating situation is welcome.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Sun 24 Apr '16 18:04    Post subject: Reply with quote

Here is my working default vhost config and a name based vhost http and https

https://gist.github.com/JBlond/5ae987627c4b6b025f1475df0c32f77d
Back to top
20160413



Joined: 13 Apr 2016
Posts: 28

PostPosted: Sun 22 May '16 2:20    Post subject: Reply with quote

Thank you for your reply and I am sorry that it took me so long to answer. Today I tried again and I am still out of luck. The diffenence between your gist and my setup is that I do not have the default 80 and 443 in apache.conf but having it in 000-default.conf and defaults-ssl.conf and loading these via apache.conf

Now I disabled all https sites on the server and I am still getting "An error occurred during a connection to www.mediawikiwidgets.org. SSL received a record that exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG" for my domain on https. Shouldn't this domain just void on https since on VirtualHost is configured for it?

I am still utterly amazed for why I run into this issue. Worked for me on Apache 1.3, 2.0 and 2.2. No idea why 2.4 is a big fail. Basically I would liked to serve a domain just over https and I would like to stay with Apache. I understand that this is a standard operation which should work right away. I now spent an total of 6 hours on this failure. I am pretty disappointed and in despair. Is there anything further I can check to get this running?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Tue 24 May '16 21:11    Post subject: Reply with quote

It seems that your server doesn't offer SSL. Are you sure mod_ssl is loaded?

Once I open in the browser
Code:
http://www.mediawikiwidgets.org:443


I get a proper redirection to bs.wikihoster.de

So I wonder how is that configured. At least I can say that on port 443 which is for https there is no SSL enabled!

try

Code:
sudo /usr/sbin/httpd -M
to see if mod ssl is enabled.

--- edit ---
See also https://www.ssllabs.com/ssltest/analyze.html?d=www.mediawikiwidgets.org&s=217.197.83.171&latest

if you don't trust the standard installation: build your own apache https://github.com/JBlond/debian_build_apache24/ Wink
Back to top
20160413



Joined: 13 Apr 2016
Posts: 28

PostPosted: Tue 24 May '16 23:10    Post subject: Reply with quote

Thank you for your patience with me. I have no idea what is going on. This is confusing and unexpected.

Indeed mod_ssl is loaded:

Code:
apache2ctl -M

Loaded Modules:
...
ssl_module (shared)
...

Why do you and up at <bs.wikihoster.de>?

"default-ssl.conf" which is enabled is being ignored and "bs.wikihoster.de.conf" is the first file with a configured 443 port which is doing a permanent redirect. That's probably why this nonsense at first glance is shown.

So why is "default-ssl.conf" being ignored though it is loaded? I just moved the file to "000-default-ssl" et voilĂ  at least I get the expected webpage on
Code:
http://www.mediawikiwidgets.org:443


I am not sure why I put <VirtualHost _default_:443> into "default-ssl.conf" and <VirtualHost *:443> in all other configured VirtualHosts if this (_default_) is being ignored. I just feels so wrong. The only thing I can imagine is to prevent the default being taken by another or several other VirtualHosts.

Still do not know why Apache 2.4 starts being so painful. Well I am in general unterbelichtet when it comes to Apache but still this appears and easy task to me.

Starting from here I will again try to get https for mediawikiwidgets.org going, probably tomorrow. I expect pain and failure. Real defeatism Wink
Back to top
20160413



Joined: 13 Apr 2016
Posts: 28

PostPosted: Sun 27 Nov '16 11:31    Post subject: End of pain Reply with quote

I did not have time to work on this since end of May. However yesterday I gave it another shot and it worked without further modifications to the config files. I dunno what went wrong in April/May. In the meantime I had about two or three updates for Apache, so a fix for an undisclosed issue I ran into was provided. Just speculating though. I am just happy that I finally can use https for Apache.

Thanks for all your time.
Back to top


Reply to topic   Topic: Configuring Apache 2.4 for SSL on Debian 8 View previous topic :: View next topic
Post new topic   Forum Index -> Apache