'HTTPS doesn't work on Vagrant (Ubuntu and Apache)
I destroyed and rebuilt my Vagrant machine and now Apache will not server anything over https. I have about 4 sites served on my machine, but even using my default site (a vagrant dashboard) I get this error (in chrome, I get different errors on FF and Safari)
This site can’t provide a secure connection
vagrant.loc sent an invalid response.
ERR_SSL_PROTOCOL_ERROR
which is not the page where I can type "thisisabadidea". I also do not see the lock icon in the url bar either.
Now, looking at my vhost files everything looks right:
<VirtualHost *:80>
ServerName vagrant.loc
ServerAlias www.vagrant.loc
ServerAdmin admin.localhost
#################################
#START Application Configuration#
#################################
DocumentRoot /srv/dashboard
DirectoryIndex index.php
<Directory "/srv/dashboard">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Header always append Content-Security-Policy "frame-ancestors vagrant.loc tools.vagrant.loc www.vagrant.loc;"
</Directory>
</VirtualHost>
<VirtualHost *:443>
# START Virtual Host Information Directives #
ServerName vagrant.loc
ServerAlias www.vagrant.loc
ServerAdmin admin.localhost
# END Virtual Host Information Directives #
SSLEngine on
SSLCertificateFile "/etc/apache2/server.crt"
SSLCertificateKeyFile "/etc/apache2/server.key"
<Directory "/srv/dashboard">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Header always append Content-Security-Policy "frame-ancestors vagrant.loc tools.vagrant.loc www.vagrant.loc;"
</Directory>
</VirtualHost>
The cert and key are in-fact in the /etc/apache2
directory. I tried to make a new self signed cert just incase the defaults were the issue but no luck.
My apache2 conf file includes a ports.conf file which has the lines:
Listen 80
Listen 443
And the following mods are enabled:
access_compat.load
alias.load
auth_basic.load
authn_core.load
authn_file.load
authz_core.load
authz_host.load
authz_user.load
autoindex.load
deflate.load
dir.load
env.load
filter.load
headers.load
mime.load
mpm_prefork.load
negotiation.load
php7.4.load
proxy_ajp.load
proxy_balancer.load
proxy_connect.load
proxy_fcgi.load
proxy_html.load
proxy_http.load
proxy.load
reqtimeout.load
rewrite.load
setenvif.load
slotmem_shm.load
socache_shmcb.load
ssl.load
status.load
xml2enc.load
running lsof -i or netstat shows apache listening on port 443:
$ netstat -ntupl | grep :443
tcp6 0 0 :::443 :::* LISTEN 10283/apache2
$ lsos -i
systemd 1 root 53u IPv4 15144 0t0 TCP *:sunrpc (LISTEN)
systemd 1 root 54u IPv4 15145 0t0 UDP *:sunrpc
systemd 1 root 55u IPv6 15148 0t0 TCP *:sunrpc (LISTEN)
systemd 1 root 56u IPv6 15151 0t0 UDP *:sunrpc
rpcbind 584 _rpc 4u IPv4 15144 0t0 TCP *:sunrpc (LISTEN)
rpcbind 584 _rpc 5u IPv4 15145 0t0 UDP *:sunrpc
rpcbind 584 _rpc 6u IPv6 15148 0t0 TCP *:sunrpc (LISTEN)
rpcbind 584 _rpc 7u IPv6 15151 0t0 UDP *:sunrpc
systemd-r 585 systemd-resolve 12u IPv4 21945 0t0 UDP localhost:domain
systemd-r 585 systemd-resolve 13u IPv4 21946 0t0 TCP localhost:domain (LISTEN)
ntpd 702 ntp 16u IPv6 22371 0t0 UDP *:ntp
ntpd 702 ntp 17u IPv4 22374 0t0 UDP *:ntp
ntpd 702 ntp 18u IPv4 22386 0t0 UDP localhost:ntp
ntpd 702 ntp 19u IPv6 22388 0t0 UDP localhost:ntp
ntpd 702 ntp 23u IPv4 26873 0t0 UDP vagrant:ntp
ntpd 702 ntp 24u IPv4 26875 0t0 UDP vagrant:ntp
ntpd 702 ntp 25u IPv6 26878 0t0 UDP vagrant:ntp
ntpd 702 ntp 26u IPv6 26880 0t0 UDP vagrant:ntp
sshd 987 root 3u IPv4 36124 0t0 TCP *:ssh (LISTEN)
sshd 987 root 4u IPv6 36126 0t0 TCP *:ssh (LISTEN)
systemd-n 1302 systemd-network 20u IPv4 84303 0t0 UDP vagrant:bootpc
mailhog 6706 vagrant 3u IPv6 52263 0t0 TCP *:1025 (LISTEN)
mailhog 6706 vagrant 5u IPv6 51844 0t0 TCP *:8025 (LISTEN)
mysqld 6784 mysql 22u IPv6 52558 0t0 TCP *:33060 (LISTEN)
mysqld 6784 mysql 24u IPv6 52561 0t0 TCP *:mysql (LISTEN)
sshd 6886 root 4u IPv4 52745 0t0 TCP vagrant:ssh->_gateway:52306 (ESTABLISHED)
sshd 6903 vagrant 4u IPv4 52745 0t0 TCP vagrant:ssh->_gateway:52306 (ESTABLISHED)
apache2 10283 root 4u IPv6 86339 0t0 TCP *:http (LISTEN)
apache2 10283 root 6u IPv6 84617 0t0 TCP *:https (LISTEN)
apache2 10285 www-data 4u IPv6 86339 0t0 TCP *:http (LISTEN)
apache2 10285 www-data 6u IPv6 84617 0t0 TCP *:https (LISTEN)
apache2 10286 www-data 4u IPv6 86339 0t0 TCP *:http (LISTEN)
apache2 10286 www-data 6u IPv6 84617 0t0 TCP *:https (LISTEN)
apache2 10287 www-data 4u IPv6 86339 0t0 TCP *:http (LISTEN)
apache2 10287 www-data 6u IPv6 84617 0t0 TCP *:https (LISTEN)
apache2 10288 www-data 4u IPv6 86339 0t0 TCP *:http (LISTEN)
apache2 10288 www-data 6u IPv6 84617 0t0 TCP *:https (LISTEN)
apache2 10289 www-data 4u IPv6 86339 0t0 TCP *:http (LISTEN)
apache2 10289 www-data 6u IPv6 84617 0t0 TCP *:https (LISTEN)
apache2 10292 www-data 4u IPv6 86339 0t0 TCP *:http (LISTEN)
apache2 10292 www-data 6u IPv6 84617 0t0 TCP *:https (LISTEN)
apache2 10293 www-data 4u IPv6 86339 0t0 TCP *:http (LISTEN)
apache2 10293 www-data 6u IPv6 84617 0t0 TCP *:https (LISTEN)
apache2 10294 www-data 4u IPv6 86339 0t0 TCP *:http (LISTEN)
apache2 10294 www-data 6u IPv6 84617 0t0 TCP *:https (LISTEN)
My logs show at least the beginning of a SSL handshake:
vagrant.loc:80 192.168.10.1 - - [21/Apr/2022:12:51:42 +0000] "\x16\x03\x01\x02" 400 491 "-" "-"
vagrant.loc:80 192.168.10.1 - - [21/Apr/2022:12:51:42 +0000] "\x16\x03\x01\x02" 400 491 "-" "-"
vagrant.loc:80 192.168.10.1 - - [21/Apr/2022:12:51:42 +0000] "\x16\x03\x01\x02" 400 491 "-" "-"
EDIT - curling the site gives me this response:
$ curl -v https://vagrant.loc
* Trying 192.168.10.175...
* TCP_NODELAY set
* Connected to vagrant.loc (192.168.10.175) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number
* Closing connection 0
curl: (35) error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|