I have Caddy installed on a Privileged Ubuntu container in my Proxmox server
a. System environment:
Ubuntu 20.04 priveledged container
b. Command:
sudo caddy start
d. My complete Caddy config:
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
books2.jveronese.com {
# Set this path to your site's directory.
# root * /usr/share/caddy
# Enable the static file server.
# file_server
# Another common task is to set up a reverse proxy:
reverse_proxy 192.168.1.68:80
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
}
3. The problem I’m having:
I have a few servers currently running on my homelab that I’d like to access without going through Cloudflare’s Zero Trust Tunnels for HTTPS. This is my current setup, but I get the error “too many redirects” when trying to access this via my web browser.
4. Error messages and/or full log output:
Output from “journalctl -u caddy --no-pager | less +G” gives me a bunch of lines with “~” followed by
-- Logs begin at Wed 2022-09-28 15:26:21 UTC, end at Wed 2022-09-28 15:26:30 UTC. --
-- No entries --
Tyring to use “curl -v” asks for a URL. Should I be using it on my domain or on the servers IP address?
This is what I get when trying it through the full URL on a different network. If that isn’t right please let me know.
C:\Users\jveronese>curl books2.jveronese.com -v
* Trying xx.xx.xx.xx:80...
* Connected to books2.jveronese.com (xx.xx.xx.xx) port 80 (#0)
> GET / HTTP/1.1
> Host: books2.jveronese.com
> User-Agent: curl/7.83.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 308 Permanent Redirect
< Connection: close
< Location: https://books2.jveronese.com/
< Server: Caddy
< Date: Wed, 28 Sep 2022 18:35:53 GMT
< Content-Length: 0
<
* Closing connection 0
5. What I already tried:
Including ports, including http://, trying a separate reverse proxy for my Nextcloud server already over HTTPS (which gives a different error)
Is Caddy even running as a systemd service then? It seems like it’s not, if you’re not even seeing Caddy’s startup logs.
This is giving expected behaviour, i.e. a redirect from HTTP to HTTPS (with the Location header) because you didn’t specify the scheme, so curl assumes HTTP.
I have seen this on fresh VPS (virtual private server) wherein journalctl does not report any logs despite the systemd unit writing them. Usually a reboot fixes it. However, this begs the question whether you’re running Caddy using systemd or just running it directly in your shell.
This fixed it. I’ve been staring at this for too long lol. This does lead me to a second issue though. I also have NextCloud running (with it’s own SSL from Let’s Encrypt). However, it resolves to an error that says
Bad Request
Your browser sent a request that this server could not understand.
You're speaking plain HTTP to an SSL-enabled server port. Instead use HTTPS scheme to access this URL.
Is there somthing I need to enable in my config to let the HTTPS talk to it? Or should I just disable HTTPS on NextCloud? Would Caddy take care of the HTTPS portion on its own?