SOLVED: V2 (beta 12): Not redirecting to https in Firefox

1. My Caddy version (caddy -version):

Note: I believe the command in the above line should be ‘caddy version’ without the dash.

bill@Bill2:~$ /usr/local/bin/caddy version
v2.0.0-beta12 h1:LZnXOGDr1SbeJNyln8Xc/hXjWCa/a9qFpCbWt2iwJPw=
bill@Bill2:~$

2. How I run Caddy:

Please provide all of the relevant information and DO NOT REDACT anything except passwords/keys. Thank you!

a. System environment:

OS, relevant versions, systemd? docker? etc.

bill@Bill2:~$ lsb_release -a
LSB Version:    core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 18.10
Release:        18.10
Codename:       cosmic
bill@Bill2:~$
bill@Bill2:~$ systemctl --version
systemd 239
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid
bill@Bill2:~$

b. Command:

bill@Bill2:~$ which caddy
/usr/local/bin/caddy
bill@Bill2:~$
bill@Bill2:~$ systemctl start caddy.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'caddy.service'.
Authenticating as: Bill,,, (bill)
Password:
==== AUTHENTICATION COMPLETE ===
bill@Bill2:~$

c. Service/unit/compose file:

bill@Bill2:~$ cat /etc/systemd/system/caddy.service
[Unit]
Description=Caddy for Glucose

[Service]
WorkingDirectory=/usr/local/caddy
ExecStart=/usr/local/bin/caddy run

[Install]
WantedBy=multi-user.target

bill@Bill2:~$

d. My complete Caddyfile:

bill@Bill2:~$ cat /usr/local/caddy/Caddyfile
wtrenker.com

matcher notStatic {
    not {
                file {
                        try_files {/home/bill/www}
                }
        }
  }

reverse_proxy match:notStatic localhost:7000
file_server browse {
    root </home/bill/www>
}
bill@Bill2:~$

3. The problem I’m having:

When I type wtrenker.com into Chrome, or Edge, the url is automatically ‘flipped over’ to https://wtrenker.com as expected and everything works great. But when I type wtrenker.com into Firefox (Version 71.0), the browser just spins and eventually times out. If I type https://wtrenker.com into Firefox manually, that works. So I must be missing some sort of information to make the automatic redirect work with Firefox. There is some mention in another topic here about needing to send something back to the browser. Something like this:

redir 301 {
  if {scheme} is http
  / https://{host}{uri}
}

Just exactly where would I put this? Thanks ever so much.

4. Error messages and/or full log output:

The browser (Firefox) times out with a page that says: “The connection has timed out”

5. What I already tried:

I tried to use the caddy.service file that comes with the Caddy installation. But I think I am stabbing around in the dark.

6. Links to relevant resources:

Putting a manual redirection block in won’t help if Firefox, for some reason, isn’t even connecting to Caddy at all. That needs to be troubleshooted in Firefox itself - or maybe in DNS? - and not in Caddy configuration, if it’s working in other browsers.

Can run a quick test - execute curl -IL http://wtrenker.com/ from the command line and post the output?

1 Like

Here is the result of the curl test. It appears to show a good redirection. I will try and troubleshoot the timeout problem in Firefox.

bill@Bill2:~$ curl -IL http://wtrenker.com/
HTTP/1.1 308 Permanent Redirect
Connection: close
Location: https://wtrenker.com/
Server: Caddy
Date: Mon, 06 Jan 2020 23:09:46 GMT

HTTP/2 200
content-type: text/html; charset=utf-8
date: Mon, 06 Jan 2020 23:09:46 GMT
server: Caddy
server: gunicorn/20.0.4
content-length: 4614

bill@Bill2:~$
2 Likes

Looking into why I don’t get an automatic redirect when trying to go to wtrenker.com in Firefox (version 71.0). I see that after a lengthy timeout the address box shows https://wtrenker.com:2015/. So Caddy did redirect to https. But I do not yet understand where port 2015 is coming from, I will continue to explore.

Tried with Firefox Private Window, or clearing all site data?

Might be some kind of cached redirect.

1 Like

Thanks to your excellent advice the problem has been solved. I first tried going to wtrenker.com in a Firefox Private Window and the https redirection worked like a charm. So that led to your next idea of clearing all site data. I did that and sure enough wtrenker.com now redirects properly in a regular Firefox Window.

Everything is fine now. Thank you so much for your help.

2 Likes