Newbie problems: Intermittent curl 308?

1. The problem I’m having:

Hi my friends, I’m extremely new to web-anything and was hoping someone could help me understand a problem I’ve been having. My website isn’t loading on any browser on any device I’ve tried. The command terminal sometimes gives an error message when I try to connect to the website via browser on various messages (see below for an example) and I get an error message from curl. Searching around other topics suggests I possibly have a configuration issue that i just don’t know enough to identify so I’m hoping someone with more experienced eyes can help out.

This is the second time this has happened; the first time it happened the issue seemed to resolve itself while I was in the middle of troubleshooting. Last time I restarted Caddy, ran apt update and apt upgrade, rebooted the sever, it was still not loading anywhere…and then everything reloaded happily about 20 minutes later into googling around trying to figure out what exactly is going on. Now it’s just not doing.

2. Error messages and/or full log output:

Here is the curl lightninggap.farm response:

curl : The remote server returned an error: (308) Permanent Redirect.
At line:1 char:1
+ curl lightninggap.farm
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

And the intermittently appearing error that has popped up in the command terminal sometimes when I try to load the page from a browser:

 2024/10/29 17:13:52.897       ERROR   http.log.error.log0     dialing backend: dial unix /run/php/php-fpm.sock: connect: resource temporarily unavailable     {"request": {"remote_ip": "174.212.161.47", "remote_port": "11841", "client_ip": "174.212.161.47", "proto": "HTTP/2.0", "method": "GET", "host": "lightninggap.farm", "uri": "/", "headers": {"User-Agent": ["Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0"], "Accept-Language": ["en-US,en;q=0.5"], "Upgrade-Insecure-Requests": ["1"], "Sec-Fetch-User": ["?1"], "Te": ["trailers"], "Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8"], "Accept-Encoding": ["gzip, deflate, br, zstd"], "Cookie": ["REDACTED"], "Sec-Fetch-Dest": ["document"], "Sec-Fetch-Mode": ["navigate"], "Sec-Fetch-Site": ["none"], "Priority": ["u=0, i"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "server_name": "lightninggap.farm"}}, "duration": 0.001375832, "status": 502, "err_id": "94gfy972i", "err_trace": "reverseproxy.statusError (reverseproxy.go:1269)"}

3. Caddy version:

v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=

4. How I installed and ran Caddy:

a. System environment:

(Imma be honest I don’t fully understand what this is asking for.)
I use a VPS running Ubuntu 20.04.6 LTS, wordpress version 6.6.2, and the PHP version output is: PHP 7.4.3-4ubuntu2.24 (cli) (built: Sep 30 2024 18:16:20) ( NTS )

I went to go look at my DNS settings to see if anything was janky but I don’t think it is. I have email forwarding through the registrar set up (porkbun) and some MailPoet txt and CNAME records for email domain verification but it all seems to check out fine.

To actually install and run caddy I used the official getting-started tutorials, and then jumped around between this tutorial and this tutorial to get wordpress running.

b. Command:

I’m also not sure what this is asking for but here’s the output for caddy start

2024/11/05 14:59:34.672 INFO    adapted config to JSON  {"adapter": "caddyfile"}
2024/11/05 14:59:34.674 INFO    admin   admin endpoint started  {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2024/11/05 14:59:34.675 INFO    http.auto_https server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {"server_name": "srv0", "https_port": 443}
2024/11/05 14:59:34.675 INFO    tls.cache.maintenance   started background certificate maintenance      {"cache": "0xc0004e2d80"}
2024/11/05 14:59:34.675 INFO    http.auto_https enabling automatic HTTP->HTTPS redirects        {"server_name": "srv0"}
2024/11/05 14:59:34.677 INFO    http    enabling HTTP/3 listener        {"addr": ":443"}
2024/11/05 14:59:34.677 INFO    http.log        server running  {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2024/11/05 14:59:34.678 INFO    http.log        server running  {"name": "remaining_auto_https_redirects", "protocols": ["h1", "h2", "h3"]}
2024/11/05 14:59:34.678 INFO    http    enabling automatic TLS certificate management   {"domains": ["lightninggap.farm"]}
2024/11/05 14:59:34.679 INFO    tls     storage cleaning happened too recently; skipping for now        {"storage": "FileStorage:/root/.local/share/caddy", "instance": "10ef2006-ffa3-4fbf-9a69-911ee1760d12", "try_again": "2024/11/06 14:59:34.679", "try_again_in": 86399.999998784}
2024/11/05 14:59:34.679 INFO    tls     finished cleaning storage units
2024/11/05 14:59:34.681 INFO    autosaved config (load with --resume flag)      {"file": "/root/.config/caddy/autosave.json"}
2024/11/05 14:59:34.681 INFO    serving initial configuration
Successfully started Caddy (pid=134877) - Caddy is running in the background

d. My complete Caddy config:

lightninggap.farm {
        # good practice to signal on behalf of who
        # are the certs getting issue
        tls lightninggapbotanical@protonmail.com

        # logs are optional
        log {
                output file /var/log/caddy/lightninggap.farm
                format console
        }

        root * /var/www/wordpress
        encode gzip
        file_server
        php_fastcgi unix//run/php/php-fpm.sock

        @disallowed {
                path /xmlrpc.php
                path *.sql
                path /wp-content/uploads/*.php
        }

        rewrite @disallowed '/index.php'
}

308 status code just means the server responded with a redirect, i.e. “try again at this other URL”, indicated by the Location header.

Also, you’re not actually using curl here. You’re using Windows’ Invoke-WebRequest program. Windows adds an alias for curl to Invoke-WebRequest which should be illegal. It’s actually insane that Microsoft did this. It lies to users, making them think they’re using https://curl.se/ when they’re not. It makes me unreasonably angry.

You can install curl on Windows in a variety of ways. Google it.

This means that Caddy can’t find the unix socket for php-fpm. Are you sure you installed PHP-FPM correctly? Are you sure that’s the location it’s using for the unix socket? It might be listening on TCP (e.g. localhost:9000) instead of using a unix socket.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.