Client sent an HTTP request to an HTTPS server

1. The problem I’m having:

I get the following message “randomly”.

Client sent an HTTP request to an HTTPS server.

Most of the time, the curl call returns with the expected results.

This is with curl to access a php page.

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"command":"/bin/ls", "runtype": "db", "unique": "xxx", "from": "host-from" }' \
  http://10.109.242.14:2015/run.php

2. Error messages and/or full log output:

Error message:

Client sent an HTTP request to an HTTPS server.”

Log:

{"level":"info","ts":1738185874.5557294,"msg":"using adjacent Caddyfile"}
{"level":"info","ts":1738185874.556667,"msg":"adapted config to JSON","adapter":"caddyfile"}
{"level":"info","ts":1738185874.557452,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
{"level":"warn","ts":1738185874.5575912,"logger":"http.auto_https","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":2015}
{"level":"info","ts":1738185874.5576637,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00051f880"}
{"level":"info","ts":1738185874.5988777,"msg":"FrankenPHP started 🐘","php_version":"8.4.3","num_threads":16}
{"level":"warn","ts":1738185874.5990632,"logger":"http","msg":"HTTP/2 skipped because it requires TLS","network":"tcp","addr":":2015"}
{"level":"warn","ts":1738185874.5990698,"logger":"http","msg":"HTTP/3 skipped because it requires TLS","network":"tcp","addr":":2015"}
{"level":"info","ts":1738185874.599075,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
{"level":"info","ts":1738185874.5993216,"msg":"autosaved config (load with --resume flag)","file":/home/40811572@ITOCSERVICES.COM/.config/caddy/autosave.json}
{"level":"info","ts":1738185874.5993297,"msg":"serving initial configuration"}
{"level":"info","ts":1738185874.602599,"logger":"tls","msg":"storage cleaning happened too recently; skipping for now","storage":"FileStorage:/home/40811572@ITOCSERVICES.COM/.local/share/caddy","instance":"4ea0917a-bfda-41ad-b93f-b07c61b53047","try_again":1738272274.6025972,"try_again_in":86399.999999637}
{"level":"info","ts":1738185874.602665,"logger":"tls","msg":"finished cleaning storage units"}

3. Caddy version:

FrankenPHP v1.4.1 PHP 8.4.3 Caddy v2.9.1 h1:OEYiZ7DbCzAWVb6TNEkjRcSCRGHVoZsJinoDR/n9oaY=

4. How I installed and ran Caddy:

Downloaded package from frankenphp.com

Run it like so:

./frankenphp run > frankenph.log 2>&1

a. System environment:

$ uname -a
Linux HRSTDBYRKS01 5.14.0-362.24.1.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Mar 14 07:33:58 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/redhat-release
Red Hat Enterprise Linux release 9.4 (Plow)
This is a “SUSE Liberty Linux 9.4”

b. Command:

./frankenphp run > frankenph.log 2>&1

d. My complete Caddy config:

{
        http_port 2015
        frankenphp
        order php_server before file_server
}

10.109.242.14:2015 {
        root * /home/40811572@ITOCSERVICES.COM/caddy
        encode zstd br gzip
        php_server
}

Using “auto_https off” doesn’t change anything. That is supposed to be unnecessary when using “http://” anyway.

{
       auto_https off
        http_port 2015
        frankenphp
        order php_server before file_server
}

10.109.242.14:2015 {
        root * /home/40811572@ITOCSERVICES.COM/caddy
        encode zstd br gzip
        php_server
}

This is the curl verbose output when it works.

/test
*   Trying 10.109.242.14:2015...
* Connected to 10.109.242.14 (10.109.242.14) port 2015 (#0)
> POST /run.php HTTP/1.1
> Host: 10.109.242.14:2015
> User-Agent: curl/7.76.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 77
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Server: Caddy
< X-Powered-By: PHP/8.4.3
< Date: Thu, 30 Jan 2025 00:30:17 GMT
< Content-Length: 23
<
* Connection #0 to host 10.109.242.14 left intact
$ exit":0,"result":"x"}

This is the curl verbose output when the error occurs.

$ ./test
*   Trying 10.109.242.14:2015...
* Connected to 10.109.242.14 (10.109.242.14) port 2015 (#0)
> POST /run.php HTTP/1.1
> Host: 10.109.242.14:2015
> User-Agent: curl/7.76.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 77
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 400 Bad Request
<
Client sent an HTTP request to an HTTPS server.
* Closing connection 0

Try to change this:

10.109.242.14:2015 {

to this:

http://10.109.242.14:2015 {

in your Caddyfile

I tried that .

No change in behavior.

Thanks, though.

It looks like my issue is that I had multiple instances of Caddy running on the same port.