Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to set up https service on my VirtualBox guest instance running Debian Squeeze and Apache 2.

When trying to load my virtual host's test page in a browser from my Win7 host machine, I'm getting an error "ssl_error_rx_record_too_long". At the same time, the Apache error log says "Invalid method in request \x16\x03\x01" for this request. The issue is probably unrelated to the fact that I'm running Apache inside a VirtualBox guest, but wanted to paint you the whole picture.

The really interesting part is that I already got to the point where the site loads properly, but only for requests coming from localhost (i.e. from within the VirtualBox Debian Guest) . I've verified this with lynx and wget, they work as expected:

wget https://ssltest.intra/ssl.html
--2013-09-13 07:26:49--  https://ssltest.intra/ssl.html
Resolving ssltest.intra (ssltest.intra)... 127.0.0.1
Connecting to ssltest.intra (ssltest.intra)|127.0.0.1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 122 [text/html]
Saving to: `ssl.html.1'

100%[======================================>] 122         --.-K/s   in 0s

2013-09-13 07:26:49 (1.94 MB/s) - `ssl.html.1' saved [122/122]

Content of the saved file is exactly as expected. Moreover, if I try to talk to the server via plain text HTTP, it rightfully sends me to a better place:

telnet ssltest.intra 443
Trying 127.0.0.1...
Connected to ssltest.intra.
Escape character is '^]'.
GET /ssl.html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Reason: You're speaking plain HTTP to an SSL-enabled server port.<br />
Instead use the HTTPS scheme to access this URL, please.<br />
<blockquote>Hint: <a href="https://ssltest.intra/"><b>https://ssltest.intra/</b></a></blockquote></p>
<hr>
<address>Apache/2.2.22 (Debian) Server at ssltest.intra Port 443</address>
</body></html>
Connection closed by foreign host.

Configuration files below (I've stripped everything from config except the bare minimum for this SSL site to work)

ports.conf:

Listen 443

httpd.conf: empty

ssltest.intra: (the virtualhost configuration)

<VirtualHost *:443>

        ServerName ssltest.intra
        ServerAdmin webmaster@ssltest.org

        SSLEngine On
        SSLCertificateFile /etc/ssl/certs/ssltest.intra.crt
        SSLCertificateKeyFile /etc/ssl/certs/ssltest.intra.key

        DocumentRoot /var/www/ssltest.intra
        Options FollowSymLinks

        <Directory /var/www/ssltest.intra/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        php_value error_log /var/www/ssltest.intra/php_errors.log
        ErrorLog /var/log/apache2/ssltest.intra.error.log
        LogLevel warn
        CustomLog /var/log/apache2/ssltest.intra.access.log combined

</VirtualHost>

I verified that cert keys are at the indicated location and they are valid (non-expired) keys for the domain. The above virtual host configuration was enabled by a2ensite ssltest.intra. mod_ssl was enabled, apache2 restarted (several times). When I start apache, this is the entry in the log:

Apache/2.2.22 (Debian) PHP/5.3.3-7+squeeze14 with Suhosin-Patch mod_ssl/2.2.22
OpenSSL/1.0.1e mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations

There are no firewall rules that would prevent any communication over 443.

What am I missing?

EDIT Apparently this has something to do with the VirtualBox network setup. When I try reaching the site locally as 127.0.0.1, everything works as expected. When I try to connect (also locally) via the other NAT-ed interface (192.168.56.10), the request is rejected. Any tips on how to resolve that?

share|improve this question

2 Answers 2

Had the same problem. In my situation the following solution worked (Apache 2.2/Debian Squeeze)

It seems like the ssl config was not loaded at the moment of listening. After many try and errors with the virtual host config, I added the config for SSL in apache2.conf instead of in the virtual host directive part. The ports are configured in ports.conf. After that my ssl worked properly. Looks like a sequence problem in loading the config parts.

Added the SSL part at the bottom of apache2.conf

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/<server certificate filename>
SSLCertificateKeyFile /etc/apache2/ssl/<privatekey filename>
SSLCACertificateFile /etc/apache2/ssl/CaCert.crt

entries already present in ports.conf

# If you just change the port or add more ports here, you will likely also
 have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
Listen 80
<IfModule mod_ssl.c>
    # SSL name based virtual hosts are not yet supported, therefore no
    # NameVirtualHost statement here
Listen 443
</IfModule>
share|improve this answer

I had the same issue because my default ssl was not enabled
In other words:

a2ensite default-ssl
service apache2 restart
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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