-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Comments
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. |
Thanks for letting us know!
That was redundant, since What exactly breaks though?
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 i am not quite sure why Edit: It seems :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 logsfor both
|
is If so, I think that's normal/expected to redirect to Edit: oh, it redirects |
redirecting |
@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 |
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
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 logsv2.5.2 h1:eCJdLyEyAGzuQTa5Mh3gETnYWDClo1LjtQm2q9RNZrs=
v2.6 logsv2.6.1 h1:EDqo59TyYWhXQnfde93Mmv4FJfYe00dO60zMiEt+pzo=
PR versione8cd495 (23 Sep 22 22:48 UTC)
Summaryresults WITH
|
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.
Wow, that's an excellent report 🤩 thanks for all the detail, that's awesome! |
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 |
No problem, glad to be able to help.
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. |
@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 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 |
No, it was always We made a change to use a separate library for the command flag parsing which disallows
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) |
i agree (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
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 |
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
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 |
sorry about the delay in response here are so logs
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
|
@arabcoders Thanks for the additional info. I was able to write a simple test case to reproduce the |
Sure, i will test it later today and report back |
Sorry about the delay, test results for
seems to be working as expected now. |
fastcgi: Redirect using original URI path (fix #5073) and rewrite: Only trim prefix if matched
Hurray! Thanks for confirming. I'll close the issue and merge that in. |
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
andhandle_path
For example this Caddyfile works for 2.5 and produce correct response.
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, otherwise308
response is returnedLogs
v2.6.1 h1:EDqo59TyYWhXQnfde93Mmv4FJfYe00dO60zMiEt+pzo=
The text was updated successfully, but these errors were encountered: