SOLVED Getting file not found vs 404 with PHPFPM

billmcollam

Member
Jan 12, 2015
22
2
53
Ontario Canada
cPanel Access Level
Reseller Owner
Just upgraded to EA4 and provisioned with PHP71 and FPM. Generally worked though a few migration issues but noticed a bunch of errors in Apache log:

Code:
proxy_fcgi AH01071: Got error "Primary script unknown
Errors where frequent but sporatic. Eventually determined they were caused by a request for *.php page that didnt exist. User would simply see 'file not found' instead of normal 404 exception page. Relavant directives in httpd.conf:
Code:
<IfModule proxy_fcgi_module>
<FilesMatch \.(phtml|php[0-9]*)$>
SetHandler proxy:unix:/opt/cpanel/ea-php71/root/usr/var/run/php-fpm/e052082a6e5649ecf631cbb5460a54c838adacd4.sock|fcgi://my.domain.com/
</FilesMatch>
</IfModule>
Presumably the proxy is getting the bad page request before my 404 exception coding can deal with it. How can I intercept these errors and perform proper 404 exception handling?
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Hello,

I believe the Apache option you are looking for is "ProxyErrorOverride":

mod_proxy - Apache HTTP Server Version 2.4

You can turn this option on with a line such as this under the "Pre Main Include" section in "WHM Home » Service Configuration » Apache Configuration » Include Editor":

Code:
ProxyErrorOverride on
Thank you.
 
  • Like
Reactions: Del Drago

billmcollam

Member
Jan 12, 2015
22
2
53
Ontario Canada
cPanel Access Level
Reseller Owner
Thanks Michael. I had read about that as a possible fix but was having challenges overriding the vhost configuration. But since it could apply to all vhosts... your suggestion was perfect. It worked fine. Many thanks.
 
  • Like
Reactions: Infopro

PeteS

Well-Known Member
Jun 8, 2017
380
85
78
Oregon
cPanel Access Level
Root Administrator

Rajeeva Lochana

Well-Known Member
Community Guide Contributor
May 27, 2019
122
38
28
India
cPanel Access Level
Root Administrator
@PeteS I made a mistake in my post btw. It is actually 'ProxyErrorOverride On', not 'Poxy'. Typo. Make sure about that. Second of all, I am not sure about webmail's way of using PHP.