I recently upgraded from Apache 2.2 to 2.4 (I know, I'm slow to upgrade, don't hate me). I have the following virtual host:
<VirtualHost _default_:30000>
DocumentRoot /opt/phpmyadmin
ErrorLog ${APACHE_LOG_DIR}/error.log
<Directory /opt/phpmyadmin>
Options -Indexes +IncludesNOEXEC +FollowSymLinks
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
LogLevel warn
</VirtualHost>
This was working previously using the Allow from all
syntax, and HTTPS is working perfectly for other virtual hosts on port 443. However, when I go to https://localhost:30000
, it serves HTTP content instead of HTTPS. This is also the only virtual host that uses port 30000, so I'm assuming it can't be due to conflicts with other virtual hosts taking precedence.
HTTPS request:
$ curl -v https://localhost:30000
* Rebuilt URL to: https://localhost:30000/
* Hostname was NOT found in DNS cache
* Trying ::1...
* Connected to localhost (::1) port 30000 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
* Closing connection 0
curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
This then produces the following in the Apache access log:
127.0.0.1:80 XXX.XXX.XXX.149 - - [04/Oct/2021:13:14:37 -0400] "\x16\x03\x01\x02" 400 0 "-" "-"
HTTP request
$ curl -v http://localhost:30000
* Rebuilt URL to: http://localhost:30000/
* Hostname was NOT found in DNS cache
* Trying ::1...
* Connected to localhost (::1) port 30000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.38.0
> Host: localhost:30000
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 04 Oct 2021 16:47:46 GMT
* Server Apache is not blacklisted
< Server: Apache
< Vary: Accept-Encoding
< Content-Length: 481
< Content-Type: text/html;charset=UTF-8
<
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Index of /</title>
</head>
<body>
<h1>Index of /</h1>
<table>
<tr><th valign="top"><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr>
<tr><th colspan="5"><hr></th></tr>
<tr><th colspan="5"><hr></th></tr>
</table>
</body></html>
Edit:
I just noticed one thing. I have -Indexes
set, but the HTTP content returned is a directory index. So I'm thinking that maybe somehow another virtual host is being used. I still don't know how that's possible since this is the only one using port 30000.
Ok, I figured out my problem. I was previously using
/etc/apache2/sites-enabled/domain
, but I needed to change it to/etc/apache2/sites-enabled/domain.conf
.In my case the virtualhost for the default
<VirtualHost _default_:443>
was missing a certificate, so I enabled the certificate with certbot, then the error\x16\x03\x01\x02
was resolved.