Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caddy 2.6.x - handle_path behavior change in relation to php_fastcgi #5073

Closed
arabcoders opened this issue Sep 23, 2022 · 21 comments · Fixed by #5076
Closed

Caddy 2.6.x - handle_path behavior change in relation to php_fastcgi #5073

arabcoders opened this issue Sep 23, 2022 · 21 comments · Fixed by #5076
Labels
bug 🐞 Something isn't working
Milestone

Comments

@arabcoders
Copy link

Hello,

i was testing caddy 2.6 to deploy on my home network, and i noticed that using the same config for 2.5 and 2.6 no longer works correctly for handle and handle_path

For example this Caddyfile works for 2.5 and produce correct response.

{
	http_port 8084
	auto_https off
	log stdout
	grace_period 10s
	debug
	admin localhost:2018
}

:8084 {
	log
	route {
		handle_path /app* {
			uri strip_prefix /app
			root * /home/user/tests/test_caddy/test

			php_fastcgi unix//var/run/php/php8.1-fpm.sock {
			}

			file_server
		}
	}
}

However using the same config for 2.6 produce 308 for /app /app/, we have to use /app/index.php to get the app to work, otherwise 308 response is returned

Logs

v2.6.1 h1:EDqo59TyYWhXQnfde93Mmv4FJfYe00dO60zMiEt+pzo=

[
    {
        "request": {
            "remote_ip": "127.0.0.1",
            "remote_port": "55046",
            "proto": "HTTP/1.1",
            "method": "GET",
            "host": "localhost:8084",
            "uri": "/app",
            "headers": {
                "User-Agent": [
                    "HTTPie/2.6.0"
                ],
                "Accept-Encoding": [
                    "gzip, deflate"
                ],
                "Accept": [
                    "*/*"
                ],
                "Connection": [
                    "keep-alive"
                ]
            }
        },
        "method": "GET",
        "uri": "/"
    },
    {
        "request": {
            "remote_ip": "127.0.0.1",
            "remote_port": "55046",
            "proto": "HTTP/1.1",
            "method": "GET",
            "host": "localhost:8084",
            "uri": "/",
            "headers": {
                "User-Agent": [
                    "HTTPie/2.6.0"
                ],
                "Accept-Encoding": [
                    "gzip, deflate"
                ],
                "Accept": [
                    "*/*"
                ],
                "Connection": [
                    "keep-alive"
                ]
            }
        },
        "method": "GET",
        "uri": "."
    },
    {
        "request": {
            "remote_ip": "127.0.0.1",
            "remote_port": "55046",
            "proto": "HTTP/1.1",
            "method": "GET",
            "host": "localhost:8084",
            "uri": "/app",
            "headers": {
                "Accept": [
                    "*/*"
                ],
                "Connection": [
                    "keep-alive"
                ],
                "User-Agent": [
                    "HTTPie/2.6.0"
                ],
                "Accept-Encoding": [
                    "gzip, deflate"
                ]
            }
        },
        "user_id": "",
        "duration": 0.00009701,
        "size": 0,
        "status": 308,
        "resp_headers": {
            "Server": [
                "Caddy"
            ],
            "Location": [
                "./"
            ],
            "Content-Type": []
        }
    },
    {
        "request": {
            "remote_ip": "127.0.0.1",
            "remote_port": "55052",
            "proto": "HTTP/1.1",
            "method": "GET",
            "host": "localhost:8084",
            "uri": "/app/",
            "headers": {
                "User-Agent": [
                    "HTTPie/2.6.0"
                ],
                "Accept-Encoding": [
                    "gzip, deflate"
                ],
                "Accept": [
                    "*/*"
                ],
                "Connection": [
                    "keep-alive"
                ]
            }
        },
        "method": "GET",
        "uri": "/"
    },
    {
        "request": {
            "remote_ip": "127.0.0.1",
            "remote_port": "55052",
            "proto": "HTTP/1.1",
            "method": "GET",
            "host": "localhost:8084",
            "uri": "/app/",
            "headers": {
                "User-Agent": [
                    "HTTPie/2.6.0"
                ],
                "Accept-Encoding": [
                    "gzip, deflate"
                ],
                "Accept": [
                    "*/*"
                ],
                "Connection": [
                    "keep-alive"
                ]
            }
        },
        "user_id": "",
        "duration": 0.000093239,
        "size": 0,
        "status": 308,
        "resp_headers": {
            "Location": [
                "/"
            ],
            "Content-Type": [],
            "Server": [
                "Caddy"
            ]
        }
    },
    {
        "request": {
            "remote_ip": "127.0.0.1",
            "remote_port": "55058",
            "proto": "HTTP/1.1",
            "method": "GET",
            "host": "localhost:8084",
            "uri": "/app/index.php",
            "headers": {
                "User-Agent": [
                    "HTTPie/2.6.0"
                ],
                "Accept-Encoding": [
                    "gzip, deflate"
                ],
                "Accept": [
                    "*/*"
                ],
                "Connection": [
                    "keep-alive"
                ]
            }
        },
        "method": "GET",
        "uri": "/index.php"
    },
    {
        "dial": "/var/run/php/php8.1-fpm.sock",
        "total_upstreams": 1
    },
    {
        "request": {
            "remote_ip": "127.0.0.1",
            "remote_port": "55058",
            "proto": "HTTP/1.1",
            "method": "GET",
            "host": "localhost:8084",
            "uri": "/index.php",
            "headers": {
                "Accept": [
                    "*/*"
                ],
                "X-Forwarded-For": [
                    "127.0.0.1"
                ],
                "User-Agent": [
                    "HTTPie/2.6.0"
                ],
                "Accept-Encoding": [
                    "gzip, deflate"
                ],
                "X-Forwarded-Proto": [
                    "http"
                ],
                "X-Forwarded-Host": [
                    "localhost:8084"
                ]
            }
        },
        "env": {
            "REQUEST_URI": "/app/index.php",
            "HTTP_ACCEPT": "*/*",
            "GATEWAY_INTERFACE": "CGI/1.1",
            "REMOTE_HOST": "127.0.0.1",
            "REMOTE_USER": "",
            "REQUEST_SCHEME": "http",
            "HTTP_HOST": "localhost:8084",
            "SERVER_PORT": "8084",
            "PATH_INFO": "",
            "REMOTE_PORT": "55058",
            "SERVER_NAME": "localhost",
            "HTTP_X_FORWARDED_FOR": "127.0.0.1",
            "REMOTE_ADDR": "127.0.0.1",
            "REMOTE_IDENT": "",
            "HTTP_ACCEPT_ENCODING": "gzip, deflate",
            "HTTP_X_FORWARDED_HOST": "localhost:8084",
            "AUTH_TYPE": "",
            "SCRIPT_FILENAME": "/home/user/tests/test_caddy/test/index.php",
            "HTTP_USER_AGENT": "HTTPie/2.6.0",
            "DOCUMENT_ROOT": "/home/user/tests/test_caddy/test",
            "REQUEST_METHOD": "GET",
            "SERVER_PROTOCOL": "HTTP/1.1",
            "CONTENT_LENGTH": "",
            "DOCUMENT_URI": "/index.php",
            "QUERY_STRING": "",
            "SERVER_SOFTWARE": "Caddy/v2.6.1",
            "SCRIPT_NAME": "/index.php",
            "HTTP_X_FORWARDED_PROTO": "http",
            "CONTENT_TYPE": ""
        },
        "dial": "/var/run/php/php8.1-fpm.sock",
        "env": {
            "GATEWAY_INTERFACE": "CGI/1.1",
            "REQUEST_URI": "/app/index.php",
            "HTTP_ACCEPT": "*/*",
            "PATH_INFO": "",
            "REMOTE_HOST": "127.0.0.1",
            "REMOTE_USER": "",
            "REQUEST_SCHEME": "http",
            "HTTP_HOST": "localhost:8084",
            "SERVER_PORT": "8084",
            "REMOTE_ADDR": "127.0.0.1",
            "REMOTE_PORT": "55058",
            "SERVER_NAME": "localhost",
            "HTTP_X_FORWARDED_FOR": "127.0.0.1",
            "AUTH_TYPE": "",
            "REMOTE_IDENT": "",
            "HTTP_ACCEPT_ENCODING": "gzip, deflate",
            "HTTP_X_FORWARDED_HOST": "localhost:8084",
            "DOCUMENT_ROOT": "/home/user/tests/test_caddy/test",
            "SCRIPT_FILENAME": "/home/user/tests/test_caddy/test/index.php",
            "HTTP_USER_AGENT": "HTTPie/2.6.0",
            "CONTENT_LENGTH": "",
            "REQUEST_METHOD": "GET",
            "SERVER_PROTOCOL": "HTTP/1.1",
            "QUERY_STRING": "",
            "DOCUMENT_URI": "/index.php",
            "CONTENT_TYPE": "",
            "SERVER_SOFTWARE": "Caddy/v2.6.1",
            "SCRIPT_NAME": "/index.php",
            "HTTP_X_FORWARDED_PROTO": "http"
        },
        "request": {
            "remote_ip": "127.0.0.1",
            "remote_port": "55058",
            "proto": "HTTP/1.1",
            "method": "GET",
            "host": "localhost:8084",
            "uri": "/index.php",
            "headers": {
                "Accept": [
                    "*/*"
                ],
                "X-Forwarded-For": [
                    "127.0.0.1"
                ],
                "User-Agent": [
                    "HTTPie/2.6.0"
                ],
                "Accept-Encoding": [
                    "gzip, deflate"
                ],
                "X-Forwarded-Proto": [
                    "http"
                ],
                "X-Forwarded-Host": [
                    "localhost:8084"
                ]
            }
        }
    },
    {
        "upstream": "unix//var/run/php/php8.1-fpm.sock",
        "duration": 0.009203193,
        "request": {
            "remote_ip": "127.0.0.1",
            "remote_port": "55058",
            "proto": "HTTP/1.1",
            "method": "GET",
            "host": "localhost:8084",
            "uri": "/index.php",
            "headers": {
                "User-Agent": [
                    "HTTPie/2.6.0"
                ],
                "Accept-Encoding": [
                    "gzip, deflate"
                ],
                "X-Forwarded-Proto": [
                    "http"
                ],
                "X-Forwarded-Host": [
                    "localhost:8084"
                ],
                "Accept": [
                    "*/*"
                ],
                "X-Forwarded-For": [
                    "127.0.0.1"
                ]
            }
        },
        "headers": {
            "Content-Type": [
                "text/html; charset=UTF-8"
            ]
        },
        "status": 200
    },
    {
        "request": {
            "remote_ip": "127.0.0.1",
            "remote_port": "55058",
            "proto": "HTTP/1.1",
            "method": "GET",
            "host": "localhost:8084",
            "uri": "/app/index.php",
            "headers": {
                "Accept-Encoding": [
                    "gzip, deflate"
                ],
                "Accept": [
                    "*/*"
                ],
                "Connection": [
                    "keep-alive"
                ],
                "User-Agent": [
                    "HTTPie/2.6.0"
                ]
            }
        },
        "user_id": "",
        "duration": 0.00955324,
        "size": 87843,
        "status": 200,
        "resp_headers": {
            "Server": [
                "Caddy"
            ],
            "Content-Type": [
                "text/html; charset=UTF-8"
            ]
        }
    }
]
@arabcoders
Copy link
Author

arabcoders commented Sep 23, 2022

I was able to somewhat fix the issue by changing the config to

:8084 {
	log
	route {
		redir /app /app/
		handle_path /app/* {
			root * /home/user/tests/test_caddy/test

			php_fastcgi unix//var/run/php/php8.1-fpm.sock {
			}

			file_server
		}
	}
}

If you feel this is not an issue, please feel free to close it i thought I'd share the issues i had upgrading.

@mholt
Copy link
Member

mholt commented Sep 23, 2022

Thanks for letting us know!

uri strip_prefix /app

That was redundant, since handle_path would do this for you.

What exactly breaks though?

redir /app /app/

Why does that fix something?

I guess I don't really understand. Some of the log entries don't make much sense as they don't look like full log lines, e.g. missing some response information (bad nesting maybe?) ...

@mholt mholt added the needs info 📭 Requires more information label Sep 23, 2022
@arabcoders
Copy link
Author

arabcoders commented Sep 23, 2022

Thanks for letting us know!

uri strip_prefix /app

That was redundant, since handle_path would do this for you.

What exactly breaks though?

redir /app /app/

Why does that fix something?

I guess I don't really understand. Some of the log entries don't make much sense as they don't look like full log lines, e.g. missing some response information (bad nesting maybe?) ...

Hi thanks for the quick reply, i copied the logs as they are from caddy using both debug and log as it is in the config up.

i am not quite sure why handle_path /app* is not working correctly, once i made the changes i maintained up there it started working it seems there is a significances for / at the end of handle_path now compared to before. let me know if you need further debugging

Edit:

It seems uri strip_prefix /app nested under handle_path was causing the problem. using this config

:8084 {
	log
	route {
		handle_path /app* {
			root * /home/user/tests/test_caddy/test
			php_fastcgi unix//var/run/php/php8.1-fpm.sock
			file_server
		}
	}
}

does work for /app/ however /app still redirect to / for some reason.

logs

for both /app and /app/

2022/09/23 17:08:34.131 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "59018", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "method": "GET", "uri": "/"}
2022/09/23 17:08:34.131 INFO    http.log.access handled request {"request": {"remote_ip": "127.0.0.1", "remote_port": "59018", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "user_id": "", "duration": 0.000131509, "size": 0, "status": 308, "resp_headers": {"Server": ["Caddy"], "Location": ["/"], "Content-Type": []}}
2022/09/23 17:08:36.503 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "59030", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "method": "GET", "uri": "/"}
2022/09/23 17:08:36.503 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "59030", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "method": "GET", "uri": "/index.php"}
2022/09/23 17:08:36.503 DEBUG   http.handlers.reverse_proxy     selected upstream       {"dial": "/var/run/php/php8.1-fpm.sock", "total_upstreams": 1}
2022/09/23 17:08:36.503 DEBUG   http.reverse_proxy.transport.fastcgi    roundtrip       {"request": {"remote_ip": "127.0.0.1", "remote_port": "59030", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/index.php", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "X-Forwarded-For": ["127.0.0.1"], "X-Forwarded-Proto": ["http"], "X-Forwarded-Host": ["localhost:8084"]}}, "env": {"SERVER_SOFTWARE": "Caddy/v2.6.1", "DOCUMENT_URI": "/index.php", "SERVER_PORT": "8084", "HTTP_X_FORWARDED_PROTO": "http", "CONTENT_TYPE": "", "REMOTE_IDENT": "", "GATEWAY_INTERFACE": "CGI/1.1", "AUTH_TYPE": "", "REMOTE_PORT": "59030", "REQUEST_SCHEME": "http", "DOCUMENT_ROOT": "/home/user/tests/test_caddy/test", "SCRIPT_NAME": "/index.php", "REMOTE_ADDR": "127.0.0.1", "SERVER_PROTOCOL": "HTTP/1.1", "HTTP_HOST": "localhost:8084", "SCRIPT_FILENAME": "/home/user/tests/test_caddy/test/index.php", "HTTP_X_FORWARDED_HOST": "localhost:8084", "CONTENT_LENGTH": "", "REMOTE_HOST": "127.0.0.1", "REMOTE_USER": "", "REQUEST_METHOD": "GET", "SERVER_NAME": "localhost", "HTTP_ACCEPT_ENCODING": "gzip, deflate", "HTTP_USER_AGENT": "HTTPie/2.6.0", "PATH_INFO": "", "HTTP_ACCEPT": "*/*", "QUERY_STRING": "", "HTTP_X_FORWARDED_FOR": "127.0.0.1", "REQUEST_URI": "/app/"}, "dial": "/var/run/php/php8.1-fpm.sock", "env": {"QUERY_STRING": "", "HTTP_ACCEPT": "*/*", "REQUEST_URI": "/app/", "HTTP_X_FORWARDED_FOR": "127.0.0.1", "HTTP_X_FORWARDED_PROTO": "http", "CONTENT_TYPE": "", "SERVER_SOFTWARE": "Caddy/v2.6.1", "DOCUMENT_URI": "/index.php", "SERVER_PORT": "8084", "REMOTE_IDENT": "", "AUTH_TYPE": "", "GATEWAY_INTERFACE": "CGI/1.1", "SCRIPT_NAME": "/index.php", "REMOTE_ADDR": "127.0.0.1", "REMOTE_PORT": "59030", "REQUEST_SCHEME": "http", "DOCUMENT_ROOT": "/home/user/tests/test_caddy/test", "HTTP_X_FORWARDED_HOST": "localhost:8084", "CONTENT_LENGTH": "", "SERVER_PROTOCOL": "HTTP/1.1", "HTTP_HOST": "localhost:8084", "SCRIPT_FILENAME": "/home/user/tests/test_caddy/test/index.php", "SERVER_NAME": "localhost", "HTTP_ACCEPT_ENCODING": "gzip, deflate", "HTTP_USER_AGENT": "HTTPie/2.6.0", "PATH_INFO": "", "REMOTE_HOST": "127.0.0.1", "REMOTE_USER": "", "REQUEST_METHOD": "GET"}, "request": {"remote_ip": "127.0.0.1", "remote_port": "59030", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/index.php", "headers": {"Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "X-Forwarded-For": ["127.0.0.1"], "X-Forwarded-Proto": ["http"], "X-Forwarded-Host": ["localhost:8084"], "User-Agent": ["HTTPie/2.6.0"]}}}
2022/09/23 17:08:36.503 DEBUG   http.handlers.reverse_proxy     upstream roundtrip      {"upstream": "unix//var/run/php/php8.1-fpm.sock", "duration": 0.000366592, "request": {"remote_ip": "127.0.0.1", "remote_port": "59030", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/index.php", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "X-Forwarded-For": ["127.0.0.1"], "X-Forwarded-Proto": ["http"], "X-Forwarded-Host": ["localhost:8084"]}}, "headers": {"Content-Type": ["text/html; charset=UTF-8"]}, "status": 200}
2022/09/23 17:08:36.503 INFO    http.log.access handled request {"request": {"remote_ip": "127.0.0.1", "remote_port": "59030", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "user_id": "", "duration": 0.000566754, "size": 3, "status": 200, "resp_headers": {"Content-Type": ["text/html; charset=UTF-8"], "Server": ["Caddy"]}}

@mholt
Copy link
Member

mholt commented Sep 23, 2022

is /home/user/tests/test_caddy/test/app a directory?

If so, I think that's normal/expected to redirect to /app/. The file server enforces canonical paths, otherwise relative links in HTML don't work.

Edit: oh, it redirects /app to /? Is that different from what you said earlier? Or what was happening before?

@arabcoders
Copy link
Author

arabcoders commented Sep 23, 2022

/home/user/tests/test_caddy/test/ is the directory containing index.php, and it's not actually redirecting to /app/ as i noticed, it's redirecting to /

2022/09/23 17:08:34.131 INFO    http.log.access handled request {"request": {"remote_ip": "127.0.0.1", "remote_port": "59018", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "user_id": "", "duration": 0.000131509, "size": 0, "status": 308, "resp_headers": {"Server": ["Caddy"], "Location": ["/"], "Content-Type": []}}

redirecting /app to /app/ is the old behavior in 2.5 i think, thats why i didn't notice it before upgrading to 2.6

@mholt
Copy link
Member

mholt commented Sep 23, 2022

@arabcoders You're sure this worked in v2.5.2 with the exact same config?

And can you please test the patch in #5076?

@arabcoders
Copy link
Author

@arabcoders You're sure this worked in v2.5.2 with the exact same config?

And can you please test the patch in #5076?

Hi replying from my phone, it's almost 12 AM where i am right now. I think i still have 2.5 version somewhere i will test both the PR version and the old version. and i'm quite sure the config i gave is exact one running in my old 2.5 setup. But to be sure i will retest them tomorrow morning.

Thanks for the quick PR

@mholt
Copy link
Member

mholt commented Sep 23, 2022

Thank you, that would be great! Have a good sleep

@mholt mholt added the bug 🐞 Something isn't working label Sep 23, 2022
@arabcoders
Copy link
Author

arabcoders commented Sep 24, 2022

Thank you, that would be great! Have a good sleep

Thank you, i have tested the following versions 2.5, 2.6, caddy_Linux_go1.19_e8cd495 which is linked in PR artifact, here are the following findings

Directory Structure

$ tree
.
├── caddy-2.5
├── caddy-2.6
├── Caddyfile
├── caddy_Linux_go1.19_e8cd495
└── test
    └── index.php

1 directory, 5 files

Caddyfile

{
        http_port 8084
        auto_https off
        log stdout
        grace_period 10s
        debug
        admin localhost:2018
}

:8084 {
        log
        route {
                handle_path /app* {
                        uri strip_prefix /app
                        root * /home/user/tests/test_caddy/test

                        php_fastcgi unix//var/run/php/php8.1-fpm.sock {
                        }

                        file_server
                }
        }
}

tested commands

$ http http://localhost:8084/app
$ http http://localhost:8084/app/
$ http http://localhost:8084/app/index.php

v2.5 logs

v2.5.2 h1:eCJdLyEyAGzuQTa5Mh3gETnYWDClo1LjtQm2q9RNZrs=

2022/09/24 01:52:34.823 INFO    serving initial configuration
2022/09/24 01:52:34.823 INFO    watcher watching config file for changes        {"config_file": "./Caddyfile"}
2022/09/24 01:52:37.905 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "47426", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app", "headers": {"Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"], "User-Agent": ["HTTPie/2.6.0"]}}, "method": "GET", "uri": "/"}
2022/09/24 01:52:37.905 INFO    http.log.access handled request {"request": {"remote_ip": "127.0.0.1", "remote_port": "47426", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "user_id": "", "duration": 0.000210572, "size": 0, "status": 308, "resp_headers": {"Location": ["/"], "Content-Type": [], "Server": ["Caddy"]}}
2022/09/24 01:52:42.990 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "49614", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/", "headers": {"Accept": ["*/*"], "Connection": ["keep-alive"], "User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"]}}, "method": "GET", "uri": "/"}
2022/09/24 01:52:42.990 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "49614", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/", "headers": {"Accept": ["*/*"], "Connection": ["keep-alive"], "User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"]}}, "method": "GET", "uri": "/index.php"}
2022/09/24 01:52:42.990 DEBUG   http.handlers.reverse_proxy     selected upstream       {"dial": "/var/run/php/php8.1-fpm.sock", "total_upstreams": 1}
2022/09/24 01:52:42.990 DEBUG   http.reverse_proxy.transport.fastcgi    roundtrip       {"request": {"remote_ip": "127.0.0.1", "remote_port": "49614", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/index.php", "headers": {"X-Forwarded-Proto": ["http"], "X-Forwarded-Host": ["localhost:8084"], "Accept": ["*/*"], "X-Forwarded-For": ["127.0.0.1"], "User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"]}}, "dial": "/var/run/php/php8.1-fpm.sock", "env": {"GATEWAY_INTERFACE": "CGI/1.1", "DOCUMENT_URI": "/index.php", "SCRIPT_NAME": "/index.php", "HTTP_ACCEPT": "*/*", "PATH_INFO": "", "REMOTE_ADDR": "127.0.0.1", "REMOTE_PORT": "49614", "SERVER_NAME": "localhost", "SERVER_PORT": "8084", "REQUEST_URI": "/app/", "HTTP_X_FORWARDED_FOR": "127.0.0.1", "QUERY_STRING": "", "REMOTE_USER": "", "HTTP_HOST": "localhost:8084", "HTTP_X_FORWARDED_HOST": "localhost:8084", "AUTH_TYPE": "", "REMOTE_HOST": "127.0.0.1", "REMOTE_IDENT": "", "CONTENT_LENGTH": "", "REQUEST_SCHEME": "http", "SERVER_PROTOCOL": "HTTP/1.1", "DOCUMENT_ROOT": "/home/user/tests/test_caddy/test", "SERVER_SOFTWARE": "Caddy/v2.5.2", "SCRIPT_FILENAME": "/home/user/tests/test_caddy/test/index.php", "HTTP_USER_AGENT": "HTTPie/2.6.0", "CONTENT_TYPE": "", "REQUEST_METHOD": "GET", "HTTP_X_FORWARDED_PROTO": "http", "HTTP_ACCEPT_ENCODING": "gzip, deflate"}}
2022/09/24 01:52:42.990 DEBUG   http.handlers.reverse_proxy     upstream roundtrip      {"upstream": "unix//var/run/php/php8.1-fpm.sock", "duration": 0.000370858, "request": {"remote_ip": "127.0.0.1", "remote_port": "49614", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/index.php", "headers": {"Accept-Encoding": ["gzip, deflate"], "X-Forwarded-Proto": ["http"], "X-Forwarded-Host": ["localhost:8084"], "Accept": ["*/*"], "X-Forwarded-For": ["127.0.0.1"], "User-Agent": ["HTTPie/2.6.0"]}}, "headers": {"Content-Type": ["text/html; charset=UTF-8"]}, "status": 200}
2022/09/24 01:52:42.990 INFO    http.log.access handled request {"request": {"remote_ip": "127.0.0.1", "remote_port": "49614", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/", "headers": {"Connection": ["keep-alive"], "User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"]}}, "user_id": "", "duration": 0.000773633, "size": 3, "status": 200, "resp_headers": {"Server": ["Caddy"], "Content-Type": ["text/html; charset=UTF-8"]}}
2022/09/24 01:52:46.961 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "49626", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/index.php", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "method": "GET", "uri": "/index.php"}
2022/09/24 01:52:46.961 DEBUG   http.handlers.reverse_proxy     selected upstream       {"dial": "/var/run/php/php8.1-fpm.sock", "total_upstreams": 1}
2022/09/24 01:52:46.961 DEBUG   http.reverse_proxy.transport.fastcgi    roundtrip       {"request": {"remote_ip": "127.0.0.1", "remote_port": "49626", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/index.php", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "X-Forwarded-For": ["127.0.0.1"], "X-Forwarded-Proto": ["http"], "X-Forwarded-Host": ["localhost:8084"]}}, "dial": "/var/run/php/php8.1-fpm.sock", "env": {"REQUEST_URI": "/app/index.php", "HTTP_ACCEPT": "*/*", "HTTP_ACCEPT_ENCODING": "gzip, deflate", "AUTH_TYPE": "", "QUERY_STRING": "", "REMOTE_PORT": "49626", "REMOTE_IDENT": "", "CONTENT_TYPE": "", "REQUEST_SCHEME": "http", "REMOTE_ADDR": "127.0.0.1", "REMOTE_HOST": "127.0.0.1", "SERVER_PROTOCOL": "HTTP/1.1", "DOCUMENT_ROOT": "/home/user/tests/test_caddy/test", "DOCUMENT_URI": "/index.php", "HTTP_HOST": "localhost:8084", "PATH_INFO": "", "SERVER_NAME": "localhost", "SERVER_SOFTWARE": "Caddy/v2.5.2", "GATEWAY_INTERFACE": "CGI/1.1", "REQUEST_METHOD": "GET", "HTTP_X_FORWARDED_FOR": "127.0.0.1", "SCRIPT_FILENAME": "/home/user/tests/test_caddy/test/index.php", "SERVER_PORT": "8084", "HTTP_X_FORWARDED_HOST": "localhost:8084", "CONTENT_LENGTH": "", "REMOTE_USER": "", "SCRIPT_NAME": "/index.php", "HTTP_X_FORWARDED_PROTO": "http", "HTTP_USER_AGENT": "HTTPie/2.6.0"}}
2022/09/24 01:52:46.961 DEBUG   http.handlers.reverse_proxy     upstream roundtrip      {"upstream": "unix//var/run/php/php8.1-fpm.sock", "duration": 0.000280623, "request": {"remote_ip": "127.0.0.1", "remote_port": "49626", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/index.php", "headers": {"X-Forwarded-For": ["127.0.0.1"], "X-Forwarded-Proto": ["http"], "X-Forwarded-Host": ["localhost:8084"], "User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"]}}, "headers": {"Content-Type": ["text/html; charset=UTF-8"]}, "status": 200}
2022/09/24 01:52:46.961 INFO    http.log.access handled request {"request": {"remote_ip": "127.0.0.1", "remote_port": "49626", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/index.php", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "user_id": "", "duration": 0.000584294, "size": 3, "status": 200, "resp_headers": {"Server": ["Caddy"], "Content-Type": ["text/html; charset=UTF-8"]}}

v2.6 logs

v2.6.1 h1:EDqo59TyYWhXQnfde93Mmv4FJfYe00dO60zMiEt+pzo=

2022/09/24 01:53:54.136 INFO    watcher watching config file for changes        {"config_file": "./Caddyfile"}
2022/09/24 01:53:59.730 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "60464", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "method": "GET", "uri": "/"}
2022/09/24 01:53:59.730 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "60464", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/", "headers": {"Connection": ["keep-alive"], "User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"]}}, "method": "GET", "uri": "."}
2022/09/24 01:53:59.730 INFO    http.log.access handled request {"request": {"remote_ip": "127.0.0.1", "remote_port": "60464", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app", "headers": {"Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"], "User-Agent": ["HTTPie/2.6.0"]}}, "user_id": "", "duration": 0.000369042, "size": 0, "status": 308, "resp_headers": {"Server": ["Caddy"], "Location": ["./"], "Content-Type": []}}
2022/09/24 01:54:04.635 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "56034", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "method": "GET", "uri": "/"}
2022/09/24 01:54:04.636 INFO    http.log.access handled request {"request": {"remote_ip": "127.0.0.1", "remote_port": "56034", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/", "headers": {"Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"], "User-Agent": ["HTTPie/2.6.0"]}}, "user_id": "", "duration": 0.000132489, "size": 0, "status": 308, "resp_headers": {"Server": ["Caddy"], "Location": ["/"], "Content-Type": []}}
2022/09/24 01:54:09.665 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "56048", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/index.php", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "method": "GET", "uri": "/index.php"}
2022/09/24 01:54:09.665 DEBUG   http.handlers.reverse_proxy     selected upstream       {"dial": "/var/run/php/php8.1-fpm.sock", "total_upstreams": 1}
2022/09/24 01:54:09.673 DEBUG   http.reverse_proxy.transport.fastcgi    roundtrip       {"request": {"remote_ip": "127.0.0.1", "remote_port": "56048", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/index.php", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "X-Forwarded-For": ["127.0.0.1"], "X-Forwarded-Proto": ["http"], "X-Forwarded-Host": ["localhost:8084"]}}, "env": {"SCRIPT_FILENAME": "/home/user/tests/test_caddy/test/index.php", "REMOTE_PORT": "56048", "SERVER_NAME": "localhost", "CONTENT_TYPE": "", "HTTP_X_FORWARDED_PROTO": "http", "DOCUMENT_ROOT": "/home/user/tests/test_caddy/test", "DOCUMENT_URI": "/index.php", "HTTP_X_FORWARDED_FOR": "127.0.0.1", "QUERY_STRING": "", "SERVER_SOFTWARE": "Caddy/v2.6.1", "SERVER_PORT": "8084", "HTTP_ACCEPT": "*/*", "HTTP_HOST": "localhost:8084", "REQUEST_URI": "/app/index.php", "SCRIPT_NAME": "/index.php", "HTTP_USER_AGENT": "HTTPie/2.6.0", "GATEWAY_INTERFACE": "CGI/1.1", "REQUEST_SCHEME": "http", "REMOTE_ADDR": "127.0.0.1", "AUTH_TYPE": "", "CONTENT_LENGTH": "", "REMOTE_USER": "", "SERVER_PROTOCOL": "HTTP/1.1", "REMOTE_IDENT": "", "PATH_INFO": "", "HTTP_ACCEPT_ENCODING": "gzip, deflate", "HTTP_X_FORWARDED_HOST": "localhost:8084", "REMOTE_HOST": "127.0.0.1", "REQUEST_METHOD": "GET"}, "dial": "/var/run/php/php8.1-fpm.sock", "env": {"DOCUMENT_ROOT": "/home/user/tests/test_caddy/test", "DOCUMENT_URI": "/index.php", "HTTP_X_FORWARDED_FOR": "127.0.0.1", "QUERY_STRING": "", "SERVER_SOFTWARE": "Caddy/v2.6.1", "SERVER_PORT": "8084", "HTTP_ACCEPT": "*/*", "HTTP_HOST": "localhost:8084", "REQUEST_URI": "/app/index.php", "SCRIPT_NAME": "/index.php", "HTTP_USER_AGENT": "HTTPie/2.6.0", "GATEWAY_INTERFACE": "CGI/1.1", "REQUEST_SCHEME": "http", "REMOTE_ADDR": "127.0.0.1", "AUTH_TYPE": "", "CONTENT_LENGTH": "", "REMOTE_USER": "", "SERVER_PROTOCOL": "HTTP/1.1", "REMOTE_IDENT": "", "PATH_INFO": "", "HTTP_ACCEPT_ENCODING": "gzip, deflate", "HTTP_X_FORWARDED_HOST": "localhost:8084", "REMOTE_HOST": "127.0.0.1", "REQUEST_METHOD": "GET", "SCRIPT_FILENAME": "/home/user/tests/test_caddy/test/index.php", "REMOTE_PORT": "56048", "SERVER_NAME": "localhost", "CONTENT_TYPE": "", "HTTP_X_FORWARDED_PROTO": "http"}, "request": {"remote_ip": "127.0.0.1", "remote_port": "56048", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/index.php", "headers": {"X-Forwarded-Host": ["localhost:8084"], "User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "X-Forwarded-For": ["127.0.0.1"], "X-Forwarded-Proto": ["http"]}}}
2022/09/24 01:54:09.674 DEBUG   http.handlers.reverse_proxy     upstream roundtrip      {"upstream": "unix//var/run/php/php8.1-fpm.sock", "duration": 0.008451788, "request": {"remote_ip": "127.0.0.1", "remote_port": "56048", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/index.php", "headers": {"X-Forwarded-Proto": ["http"], "X-Forwarded-Host": ["localhost:8084"], "User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "X-Forwarded-For": ["127.0.0.1"]}}, "headers": {"Content-Type": ["text/html; charset=UTF-8"]}, "status": 200}
2022/09/24 01:54:09.674 INFO    http.log.access handled request {"request": {"remote_ip": "127.0.0.1", "remote_port": "56048", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/index.php", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "user_id": "", "duration": 0.008650907, "size": 3, "status": 200, "resp_headers": {"Server": ["Caddy"], "Content-Type": ["text/html; charset=UTF-8"]}}

PR version

e8cd495 (23 Sep 22 22:48 UTC)

2022/09/24 01:55:03.848 INFO    watcher watching config file for changes        {"config_file": "./Caddyfile"}
2022/09/24 01:55:08.981 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "38500", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app", "headers": {"Connection": ["keep-alive"], "User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"]}}, "method": "GET", "uri": "/"}
2022/09/24 01:55:08.981 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "38500", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "method": "GET", "uri": "."}
2022/09/24 01:55:08.981 INFO    http.log.access handled request {"request": {"remote_ip": "127.0.0.1", "remote_port": "38500", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "user_id": "", "duration": 0.000129626, "size": 0, "status": 308, "resp_headers": {"Server": ["Caddy"], "Location": ["/app/"], "Content-Type": []}}
2022/09/24 01:55:15.207 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "43052", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "method": "GET", "uri": "/"}
2022/09/24 01:55:15.207 INFO    http.log.access handled request {"request": {"remote_ip": "127.0.0.1", "remote_port": "43052", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/", "headers": {"Connection": ["keep-alive"], "User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"]}}, "user_id": "", "duration": 0.000099804, "size": 0, "status": 308, "resp_headers": {"Server": ["Caddy"], "Location": ["/app//"], "Content-Type": []}}
2022/09/24 01:55:26.147 DEBUG   http.handlers.rewrite   rewrote request {"request": {"remote_ip": "127.0.0.1", "remote_port": "42348", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/index.php", "headers": {"Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"], "User-Agent": ["HTTPie/2.6.0"]}}, "method": "GET", "uri": "/index.php"}
2022/09/24 01:55:26.147 DEBUG   http.handlers.reverse_proxy     selected upstream       {"dial": "/var/run/php/php8.1-fpm.sock", "total_upstreams": 1}
2022/09/24 01:55:26.147 DEBUG   http.reverse_proxy.transport.fastcgi    roundtrip       {"request": {"remote_ip": "127.0.0.1", "remote_port": "42348", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/index.php", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "X-Forwarded-For": ["127.0.0.1"], "X-Forwarded-Proto": ["http"], "X-Forwarded-Host": ["localhost:8084"]}}, "env": {"REQUEST_METHOD": "GET", "HTTP_ACCEPT_ENCODING": "gzip, deflate", "HTTP_X_FORWARDED_FOR": "127.0.0.1", "AUTH_TYPE": "", "QUERY_STRING": "", "REMOTE_ADDR": "127.0.0.1", "HTTP_ACCEPT": "*/*", "CONTENT_LENGTH": "", "CONTENT_TYPE": "", "DOCUMENT_ROOT": "/home/user/tests/test_caddy/test", "REMOTE_USER": "", "SERVER_SOFTWARE": "Caddy/e8cd4957-20220923", "PATH_INFO": "", "REMOTE_HOST": "127.0.0.1", "SERVER_NAME": "localhost", "HTTP_X_FORWARDED_HOST": "localhost:8084", "GATEWAY_INTERFACE": "CGI/1.1", "HTTP_USER_AGENT": "HTTPie/2.6.0", "HTTP_X_FORWARDED_PROTO": "http", "REMOTE_IDENT": "", "DOCUMENT_URI": "/index.php", "REQUEST_URI": "/app/index.php", "SCRIPT_NAME": "/index.php", "SERVER_PORT": "8084", "REMOTE_PORT": "42348", "REQUEST_SCHEME": "http", "SCRIPT_FILENAME": "/home/user/tests/test_caddy/test/index.php", "SERVER_PROTOCOL": "HTTP/1.1", "HTTP_HOST": "localhost:8084"}, "dial": "/var/run/php/php8.1-fpm.sock", "env": {"GATEWAY_INTERFACE": "CGI/1.1", "HTTP_USER_AGENT": "HTTPie/2.6.0", "HTTP_X_FORWARDED_PROTO": "http", "HTTP_X_FORWARDED_HOST": "localhost:8084", "REMOTE_IDENT": "", "DOCUMENT_URI": "/index.php", "REQUEST_URI": "/app/index.php", "SERVER_PORT": "8084", "REMOTE_PORT": "42348", "REQUEST_SCHEME": "http", "SCRIPT_FILENAME": "/home/user/tests/test_caddy/test/index.php", "SCRIPT_NAME": "/index.php", "SERVER_PROTOCOL": "HTTP/1.1", "HTTP_HOST": "localhost:8084", "HTTP_ACCEPT_ENCODING": "gzip, deflate", "HTTP_X_FORWARDED_FOR": "127.0.0.1", "AUTH_TYPE": "", "QUERY_STRING": "", "REMOTE_ADDR": "127.0.0.1", "REQUEST_METHOD": "GET", "CONTENT_LENGTH": "", "CONTENT_TYPE": "", "DOCUMENT_ROOT": "/home/user/tests/test_caddy/test", "HTTP_ACCEPT": "*/*", "REMOTE_USER": "", "PATH_INFO": "", "REMOTE_HOST": "127.0.0.1", "SERVER_NAME": "localhost", "SERVER_SOFTWARE": "Caddy/e8cd4957-20220923"}, "request": {"remote_ip": "127.0.0.1", "remote_port": "42348", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/index.php", "headers": {"X-Forwarded-Host": ["localhost:8084"], "User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "X-Forwarded-For": ["127.0.0.1"], "X-Forwarded-Proto": ["http"]}}}
2022/09/24 01:55:26.148 DEBUG   http.handlers.reverse_proxy     upstream roundtrip      {"upstream": "unix//var/run/php/php8.1-fpm.sock", "duration": 0.000328324, "request": {"remote_ip": "127.0.0.1", "remote_port": "42348", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/index.php", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "X-Forwarded-For": ["127.0.0.1"], "X-Forwarded-Proto": ["http"], "X-Forwarded-Host": ["localhost:8084"]}}, "headers": {"Content-Type": ["text/html; charset=UTF-8"]}, "status": 200}
2022/09/24 01:55:26.148 INFO    http.log.access handled request {"request": {"remote_ip": "127.0.0.1", "remote_port": "42348", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8084", "uri": "/app/index.php", "headers": {"User-Agent": ["HTTPie/2.6.0"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "Connection": ["keep-alive"]}}, "user_id": "", "duration": 0.000564877, "size": 3, "status": 200, "resp_headers": {"Server": ["Caddy"], "Content-Type": ["text/html; charset=UTF-8"]}}

Summary

results WITH uri strip_prefix /app

Version Path Status Response
v2.5 /app 308 Location: /
v2.6 /app 308 Location: ./
vPR /app 308 Location: /app/
v2.5 /app/ 200 shows php output
v2.6 /app/ 308 Location: /
vPR /app/ 308 Location: /app//
v2.5 /app/index.php 200 shows php output
v2.6 /app/index.php 200 shows php output
vPR /app/index.php 200 shows php output

results WITHOUT uri strip_prefix /app

Version Path Status Response
v2.5 /app 308 Location: /
v2.6 /app 308 Location: ./
vPR /app 308 Location: /app/
v2.5 /app/ 200 shows php output
v2.6 /app/ 200 shows php output
vPR /app/ 200 shows php output
v2.5 /app/index.php 200 shows php output
v2.6 /app/index.php 200 shows php output
vPR /app/index.php 200 shows php output

it seems uri strip_prefix /app somehow altering the path even though it should have 0 effect as you indicated it being redundant.

@francislavoie
Copy link
Member

francislavoie commented Sep 24, 2022

Wow, that's an excellent report 🤩 thanks for all the detail, that's awesome!

@mholt
Copy link
Member

mholt commented Sep 24, 2022

Oh wow, thank you for the well-organized report. I'll investigate more! But I think we're making progress and it looks like things are mostly working as expected, right? Just a few little quirks to iron out. (Like sending 308 to /app// -- or perhaps, that uri strip_prefix /app has effect when it shouldn't.)

@arabcoders
Copy link
Author

No problem, glad to be able to help.

Just a few little quirks to iron out. (Like sending 308 to /app// -- or perhaps, that uri strip_prefix /app has effect when it shouldn't.)

I think so too, it seems strip_prefix is doing something that it should not do, in my opinion, strip_prefix should return uri as it is if the path does not match. i think probably its quirk in the Caddyfile parser and the reordering maybe? but then again route directive should override automatic re-ordering. Honestly i have little golang experience to dig deeper in caddy internals.

@arabcoders
Copy link
Author

arabcoders commented Sep 24, 2022

@mholt i found two other odd problems, one seems to be breaking change although small, and another problem regarding caddy reload not picking up changes unless restart is done

the breaking change is in caddy fmt, overwrite used to be -overwrite in 2.5 while in 2.6 is --overwrite

the other problem in config reload is it seems it relates to http/3 keep alive connection? not exactly sure i'll have to dig more tomorrow

@francislavoie
Copy link
Member

francislavoie commented Sep 24, 2022

the breaking change is in caddy fmt, overwrite used to be -overwrite in 2.5 while in 2.6 is --overwrite

No, it was always --overwrite, but it just happened that Go's out-of-the-box command flag parsing also allowed -overwrite. But you should have been using two dashes.

We made a change to use a separate library for the command flag parsing which disallows -overwrite which opens us up to be able to provide some single-letter flag shortcuts like -w instead (we didn't add these in yet, but we will soon). #4565

the other problem in config reload is it seems it relates to http/3 keep alive connection? not exactly sure i'll have to dig more tomorrow

I don't understand. Please elaborate in detail. What behaviour are you seeing? What's the problem exactly? (No rush, just want to mention that this isn't actionable as-is)

@arabcoders
Copy link
Author

arabcoders commented Sep 24, 2022

the breaking change is in caddy fmt, overwrite used to be -overwrite in 2.5 while in 2.6 is --overwrite

No, it was always --overwrite, but it just happened that Go's out-of-the-box command flag parsing also allowed -overwrite. But you should have been using two dashes.

We made a change to use a separate library for the command flag parsing which disallows -overwrite which opens us up to be able to provide some single-letter flag shortcuts like -w instead (we didn't add these in yet, but we will soon). #4565

i agree -- is for long-opts and - for short-opts, caddy used to report this though

(00:40:40) user@server ~/tests/test_caddy
$ ./caddy-2.5 version
v2.5.2 h1:eCJdLyEyAGzuQTa5Mh3gETnYWDClo1LjtQm2q9RNZrs=
(00:40:41) user@server ~/tests/test_caddy
$ ./caddy-2.5 fmt -h
Usage of fmt:
  -diff
        Print the differences between the input file and the formatted output
  -overwrite
        Overwrite the input file with the results

i remember being confused why -overwrite was a thing and didn't expect --overwrite to work, i only noticed it in one of my container builds failing as it was doing caddy fmt -overwrite config.

I don't understand. Please elaborate in detail. What behaviour are you seeing? What's the problem exactly? (No rush, just want to mention that this isn't actionable as-is)

Sure, I'll hopefully have more information tomorrow as i dig more into it but right now, this is the behavior i am noticing.

have a caddy server running, edit the config do caddy reload, i expect the changes to caddyfile file to be reflected in the running server, however thats not happening i have grace_period set to 5s. it should reload correctly. However the config is not reflected until i do caddy stop and caddy start

@francislavoie
Copy link
Member

i agree -- is for long-opts and - for short-opts, caddy used to report this though

Which was part of the problem we were trying to solve. We couldn't control this, because the Go stdlib produced the help doc itself, and always used - for flags. Our docs on the website always documented -- https://caddyserver.com/docs/command-line. Go is weirdly opinionated about that, and doesn't match most people's expectations from posix-typical command-line conventions.

have a caddy server running, edit the config do caddy reload, i expect the changes to caddyfile file to be reflected in the running server, however thats not happening i have grace_period set to 5s. it should reload correctly. However the config is not reflected until i do caddy stop and caddy start

What's in your logs when you reload? What do you see when you query the admin endpoint to get your current config (or what's in your autosave.json?)

@arabcoders
Copy link
Author

arabcoders commented Sep 25, 2022

i agree -- is for long-opts and - for short-opts, caddy used to report this though

Which was part of the problem we were trying to solve. We couldn't control this, because the Go stdlib produced the help doc itself, and always used - for flags. Our docs on the website always documented -- https://caddyserver.com/docs/command-line. Go is weirdly opinionated about that, and doesn't match most people's expectations from posix-typical command-line conventions.

have a caddy server running, edit the config do caddy reload, i expect the changes to caddyfile file to be reflected in the running server, however thats not happening i have grace_period set to 5s. it should reload correctly. However the config is not reflected until i do caddy stop and caddy start

What's in your logs when you reload? What do you see when you query the admin endpoint to get your current config (or what's in your autosave.json?)

sorry about the delay in response here are so logs

Sep 25 19:23:17 server systemd[1]: Reloading Caddy...
Sep 25 19:23:17 server caddy[3104843]: {"level":"info","ts":1664122997.080133,"msg":"using provided configuration","config_file":"/backup/src/apps/caddy/config/Caddyfile","config_adapter":"caddyfile"}
Sep 25 19:23:17 server caddy[1971982]: {"level":"info","ts":1664122997.1032093,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_ip":"127.0.0.1","remote_port":"60110","headers":{"Accept-Encoding":["gzip"],"Content-Length":["95248"],"Content-Type":["application/json"],"Origin":["http://localhost:2019"],"User-Agent":["Go-http-client/1.1"]}}
Sep 25 19:23:17 server caddy[1971982]: {"level":"info","ts":1664122997.1124263,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
Sep 25 19:23:17 server caddy[1971982]: {"level":"info","ts":1664122997.1133099,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc0003d9b20"}
Sep 25 19:23:17 server caddy[1971982]: {"level":"warn","ts":1664122997.1138237,"logger":"http","msg":"automatic HTTPS is completely disabled for server","server_name":"srv1"}
Sep 25 19:23:17 server caddy[1971982]: {"level":"warn","ts":1664122997.1139197,"logger":"http","msg":"automatic HTTPS is completely disabled for server","server_name":"srv0"}
Sep 25 19:23:17 server caddy[1971982]: {"level":"info","ts":1664122997.1252217,"logger":"http","msg":"enabling HTTP/3 listener","addr":":443"}
Sep 25 19:23:17 server caddy[1971982]: {"level":"info","ts":1664122997.125249,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
Sep 25 19:23:17 server caddy[1971982]: {"level":"info","ts":1664122997.1252747,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/backup/src/apps/caddy/data/caddy"}
Sep 25 19:23:17 server caddy[1971982]: {"level":"info","ts":1664122997.1252756,"logger":"http.log","msg":"server running","name":"srv1","protocols":["h1","h2","h3"]}
Sep 25 19:23:17 server caddy[1971982]: {"level":"error","ts":1664122997.1253626,"logger":"http","msg":"server shutdown","error":"context canceled","addresses":[":443"]}
Sep 25 19:23:17 server caddy[1971982]: {"level":"info","ts":1664122997.1253877,"logger":"tls","msg":"finished cleaning storage units"}
Sep 25 19:23:17 server caddy[1971982]: {"level":"info","ts":1664122997.1255283,"logger":"tls.cache.maintenance","msg":"stopped background certificate maintenance","cache":"0xc0005c98f0"}
Sep 25 19:23:17 server caddy[1971982]: {"level":"info","ts":1664122997.125717,"msg":"autosaved config (load with --resume flag)","file":"/backup/src/apps/caddy/config/caddy/autosave.json"}
Sep 25 19:23:17 server caddy[1971982]: {"level":"info","ts":1664122997.1257472,"logger":"admin.api","msg":"load complete"}
Sep 25 19:23:17 server caddy[1971982]: {"level":"info","ts":1664122997.1280487,"logger":"admin","msg":"stopped previous server","address":"localhost:2019"}
Sep 25 19:23:17 server systemd[1]: Reloaded Caddy.
Sep 25 19:23:23 server caddy[1971982]: {"level":"error","ts":1664123003.250678,"logger":"http.log","msg":"setting HTTP/3 Alt-Svc header","error":"no port can be announced, specify it explicitly using Server.Port or Server.Addr"}

here is the systemd service file and the command used to reload. was working fine on 2.5

[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target

[Service]
Type=notify
User=caddy
Group=caddy
Environment=TZ=Asia/Kuwait
Environment=XDG_DATA_HOME=/backup/src/apps/caddy/data
Environment=XDG_CONFIG_HOME=/backup/src/apps/caddy/config
ExecStartPre=/usr/local/bin/caddy validate --config /backup/src/apps/caddy/config/Caddyfile --adapter caddyfile
ExecStart=/usr/local/bin/caddy run --environ --config /backup/src/apps/caddy/config/Caddyfile --adapter caddyfile
ExecReload=/usr/local/bin/caddy reload --config /backup/src/apps/caddy/config/Caddyfile --adapter caddyfile
TimeoutStopSec=5s
#LimitNOFILE=1048576
#LimitNPROC=512
#PrivateTmp=true
#ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

autosave.json is being updated however the changes are not reflected, unless i do systemctl restart caddy

@mholt
Copy link
Member

mholt commented Sep 28, 2022

@arabcoders Thanks for the additional info. I was able to write a simple test case to reproduce the /app// output and I pushed an additional commit to #5076. Can you try the latest on that branch and see if you still get the odd behavior? It should fix the issue with uri strip_prefix.

@mholt mholt removed the needs info 📭 Requires more information label Sep 28, 2022
@arabcoders
Copy link
Author

@arabcoders Thanks for the additional info. I was able to write a simple test case to reproduce the /app// output and I pushed an additional commit to #5076. Can you try the latest on that branch and see if you still get the odd behavior? It should fix the issue with uri strip_prefix.

Sure, i will test it later today and report back

@arabcoders
Copy link
Author

@arabcoders Thanks for the additional info. I was able to write a simple test case to reproduce the /app// output and I pushed an additional commit to #5076. Can you try the latest on that branch and see if you still get the odd behavior? It should fix the issue with uri strip_prefix.

Sorry about the delay, test results for caddy_Linux_go1.19_ddff570

$ http localhost:8084/app
HTTP/1.1 308 Permanent Redirect
Content-Length: 0
Date: Wed, 28 Sep 2022 21:19:19 GMT
Location: /app/
Server: Caddy



(00:19:19) user@server ~/tests/test_caddy
$ http localhost:8084/app/
HTTP/1.1 200 OK
Content-Length: 3
Content-Type: text/html; charset=UTF-8
Date: Wed, 28 Sep 2022 21:19:20 GMT
Server: Caddy

foo

(00:19:20) user@server ~/tests/test_caddy
$ http localhost:8084/app/index.php
HTTP/1.1 200 OK
Content-Length: 3
Content-Type: text/html; charset=UTF-8
Date: Wed, 28 Sep 2022 21:19:23 GMT
Server: Caddy

foo

(00:19:23) user@server ~/tests/test_caddy

seems to be working as expected now.

@mholt mholt linked a pull request Sep 28, 2022 that will close this issue
mholt added a commit that referenced this issue Sep 28, 2022
fastcgi: Redirect using original URI path (fix #5073) and rewrite: Only trim prefix if matched
@mholt
Copy link
Member

mholt commented Sep 28, 2022

Hurray! Thanks for confirming. I'll close the issue and merge that in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants