Non existent php file

Related to:

When an non existent php file is requested, although a 404 is sent back to the requester, a Primary script unknown error is also thrown in the error log and the custom 404 file is also not served. That custom file is however correctly served for any other non-existent file with a extension different from .php

Config file:

example.com {
	fastcgi / /var/run/php/php7.0-fpm.sock php {
		index index.php login.php
	}

	errors /var/log/caddy/error.log {
		404  /var/www/err_img/404.html
	}
	index index.php
	root /var/www
}

@abiosoft - What do you think, is this what we expect? I honestly haven’t used PHP in so long I can’t even remember. :slight_smile:

That is not expected, I will dig more into this.

The reason is that fastcgi server responds with a body and Caddy prioritises the upstream response over writing another response.

Maybe we should make it user configurable for Caddy to override fastcgi upstream response body when the response code is > 400.

Thanks for looking into it!

That seems like a good idea. If I recall correctly, that is how it is done on other servers too.

Is this related to these?
https://github.com/mholt/caddy/issues/1961
https://github.com/mholt/caddy/pull/1975

1 Like

No, that is another issue. Not related.

By the way, thanks for bringing that up. I’ve forgotten about that pull request and it needs my review.

1 Like

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