Apache not serving HTTPS to localhost

singpolyma asked:

This just started being a problem (likely after a software upgrade?). The relevant config bits are:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName singpolyma.net
    ServerAlias www.singpolyma.net
    RewriteEngine on
    RewriteRule ^/(.*) https://singpolyma.net/$1 [R=301,L]

    GnuTLSEnable on
    GnuTLSPriorities NORMAL
    GnuTLSCertificateFile /etc/ssl/certs/singpolyma.net2013.crt
    GnuTLSKeyFile /etc/ssl/certs/singpolyma.net2013.key

From everywhere that is not the local box, this works as expected. When I try to connect from the box itself, I get apaching replying on 443 on that IP with non-HTTPS. When I run curl with --interface and ask it to use a different interface than the one that hosts that IP, then it also works fine, even on the box.

So something strange is happening, just when I do a local request.

My answer:

In your https virtual host, you specified an IP address to listen for connections on. Thus, requests which connect to any other IP address on the host will never match that virtual host.

If you really wanted to do this, you could add a second IP address to the <VirtualHost> declaration, or just make it a wildcard *:443.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.