Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED Getting file not found vs 404 with PHPFPM

Discussion in 'EasyApache' started by billmcollam, May 6, 2017.

Tags:
  1. billmcollam

    billmcollam Member

    Joined:
    Jan 12, 2015
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    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?
     
    #1 billmcollam, May 6, 2017
    Last edited by a moderator: May 6, 2017
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,427
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
  3. billmcollam

    billmcollam Member

    Joined:
    Jan 12, 2015
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    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.
     
    Infopro likes this.
Loading...

Share This Page