After switching a website to FPM served by nginx in Plesk, it fails to load with "404 Not Found" on all pages except start page

Follow

Comments

56 comments

  • Avatar
    Ivan Postnikov

    Hello @DoSieci,

    Your case requires the additional investigation.

    Please, submit a ticket to Plesk support, this will let us have a closer look at the issue.

     

    0
    Comment actions Permalink
  • Avatar
    Oleg Burca

    Plesk team,

    Can you please add instructions for Obsidian also?

    Thank you!

    0
    Comment actions Permalink
  • Avatar
    Julian Bonpland Mignaquy

    Hi Oleg Burca,
    I just run the solution on our test servers and the same applies for Onyx and Obsidian. Make sure that you are replacing the entire block:

    <?php if ($VAR->domain->physicalHosting->directoryIndex): ?>
    location ~ /$ {
    index <?=$VAR->quote($VAR->domain->physicalHosting->directoryIndex)?>;
    }
    <?php endif ?>

    with

    location ~ / {
    index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
    try_files $uri $uri/ /index.php$is_args$args;
    }

     

    0
    Comment actions Permalink
  • Avatar
    Jorge Salazar

    Hi Kuzma Ivanov,

    I am tried to add this code to the file /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php as explained in step 3 but in Plesk Obsidian the block of code that we need to replace is not exactly like the one you mentioned there.

     

    In my case the block of code I can see similar to the one mentioned here is this one (start at line:155 ):

    <?php if ($VAR->domain->physicalHosting->directoryIndex && !$VAR->domain->physicalHosting->proxySettings['nginxProxyMode']): ?>
    location ~ /$ {
    index <?=$VAR->quote($VAR->domain->physicalHosting->directoryIndex)?>;
    }
    <?php endif ?>

     

    Could you please check it and let us know what would be the bock of code to replace for Obsidian?

     

    Regards.

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello @Jorge,

    The following config is to be replaced on Plesk Obsidian:

    <?php if ($VAR->domain->physicalHosting->directoryIndex && !$VAR->domain->physicalHosting->proxySettings['nginxProxyMode']): ?>
    location ~ /$ {
    index <?=$VAR->quote($VAR->domain->physicalHosting->directoryIndex)?>;
    }
    <?php endif ?>

    I've successfully tested it.

    The article will be updated.

    0
    Comment actions Permalink
  • Avatar
    Brian Lamb (Edited )

    Thank you @Denis Bykov

    This worked for me.  I run about 30 WP sites. What worked for me, was using the custom template.  I used the Plesk 17.8 settings above, under "For all existing and newly created websites in Plesk Onyx & Obsidian" . 

    e.g.

    location ~ / {
    index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
    try_files $uri $uri/ /index.php$is_args$args;
    }

    This was the only way i could get the question mark out of the urls. For some sites the standard overrides, that you can add in "Additional nginx directives" would not work in some cases. 

    Note, to properly test that, you need to reset permalinks in some cases.  To do that, change them to Plain, CLICK SAVE, then Change them back, and click save.   Ignore the SEO warning when you do this. 

    Boun Vilailath, and all others having the question mark showing up still in their url, breaking pages, I wanted to say, i had the exact same issue, this resolved it for me, only after i removed the old settings that i had in the nginx/apache overrides.  so be sure to remove those after you add the new directives to a custom template.  

    e.g. the old settings are whats pointed out in the single site directive, which did not work for me on some sites.


    if (!-e $request_filename) {
    set $test P;
    }
    if ($uri !~ ^/(plesk-stat|webstat|webstat-ssl|ftpstat|anon_ftpstat|awstats-icon|internal-nginx-static-location)) {
    set $test "${test}C";
    }
    if ($test = PC) {
    rewrite ^/(.*)$ /index.php?$1;
    }

    Notice the rewrite rule there.  Thats whats adding the question mark.

    You need to use the full location block directive if your having the question mark still showing up, atleast for my version of Plesk (17.8). 

    Note, the title of the article is decieving, i never received a 404 not found, this because the home page url was still loading, the portion after the slash, e.g. /?about was not loading, due the question mark. So no 404 ever happened. Instead as mentioned, i just saw the home page.  SO they didnt 404, they just didnt work.  Hence, this article threw me off at first (weeks prior), in the sea of other help articles on this, i thought it was irrelavant, however in the end i found it was.  So it may help lots of other developers to update the title!!

    0
    Comment actions Permalink
  • Avatar
    Koray Snoray

    this works, but the mail autosdiscovery is broken after this.. 

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello Koray Snoray

    Please, check my response at https://support.plesk.com/hc/en-us/articles/360009747280

    0
    Comment actions Permalink
  • Avatar
    Brian Lamb

    For me, which also happened last night, this also breaks mailman.  We have mailman as a subdomain. Adding the overrides in either the global config override, or the parent domain (WP Site) it breaks mailman subdomain. 

    Is there an override that i can maybe add to the subdomain?  its kind of sad that the subdomain picks it up anyway, because this is just for this particular site on the parent domain.  I guess thats the nature of how the subdomain loads.  

    I at first thought the mention above for "mail" was a potential resolution for me as well, but im not sure what the "mail autodiscovery" is, so im thinking thats not related.

    0
    Comment actions Permalink
  • Avatar
    Ekaterina Babenko

    Hello Brian,

    Mail Autodiscovery is functionality that allows email clients such as Thunderbird or Outlook pick up all information about mail server automatically.

    Please, take a note that we are not aware if the workaround described in the article affects Mail Autodiscovery. To assist you better on that case, please, submit request to support team and we will check Mailman issue along with any others if arise:
    https://support.plesk.com/hc/en-us/articles/213608509-How-to-submit-a-request-to-Plesk-support-

    0
    Comment actions Permalink
  • Avatar
    Andy Little

    I have "FPM served by Nginx" enabled on all our WordPress subscriptions and they all work. Apache rewrite rules are still working. Is this a bug?

     

    Everywhere I look it says .htaccess won't be processed if "FPM served by Nginx" is enabled. I haven't added any Additional Nginx directives. The sites just work.

     

    Can anyone explain this?

    0
    Comment actions Permalink
  • Avatar
    Francisco Garcia

    Hi Andy Little,

    The Wordpress Toolkit extension now adds automatically some configuration on Nginx in order to make work the permalinks.

    0
    Comment actions Permalink
  • Avatar
    Andy Little

    Hi Francisco Garcia,

    That would make sense, however, my Magento sites all work with FPM served by Nginx and they use htaccess rewrite rules.

    Thanks

    0
    Comment actions Permalink
  • Avatar
    Francisco Garcia

    Hi Andy Little,

    I could test this behavior in a test environment, and what I could deduct from it is that it's something implemented in magento2-core, as this only happens with Magento, not with a regular PHP test page.

    0
    Comment actions Permalink
  • Avatar
    Andy Little

    Thanks Francisco Garcia,

    Actually, it's all our Magento sites (M1 and M2) and all our WordPress sites. They all work with FPM served with Nginx and I've not had to make any special accommodations. Literally all I did was switch to "FPM served by Nginx" in the PHP settings and that's it. They all still work. No issues with redirects as others have described. 

    From what I've read, this shouldn't be the case. 

    In the Apache and Nginx settings, Nginx is set in proxy mode. I'm not sure if this is why, but nowhere else does anyone mentioned disabling this before getting the 404 errors.

    Thanks again

    0
    Comment actions Permalink
  • 1
    Comment actions Permalink
  • Avatar
    Andy Little

    Hi Francisco Garcia,

    Is this the bug "PHP continues to be served by Apache when Proxy mode is enabled. The behaviour has been confirmed as Plesk bug PPPM-11234".

    That would make sense and would explain why my apps all work even with "FPM served by Nginx" enabled.

    I guess if I turn off Proxy Mode I will experience the same issues as the others in this thread?

    Thanks

    0
    Comment actions Permalink
  • Avatar
    Francisco Garcia

    Hi Andy Little,

    If you turn off Proxy mode, then the webserver won't use .htaccess rewrite rules. Then, yes, you should use the resolution from this article.

    1
    Comment actions Permalink
  • Avatar
    Andy Little

    Hi Francisco Garcia,

    Great. At least I know it's due to Proxy Mode. I just wasn't sure why I wasn't getting the same error as others in this thread. Maybe the article should be updated to state this only happens if Proxy mode is disabled?

    Thanks

    0
    Comment actions Permalink
  • Avatar
    Francisco Garcia

    Hi Andy Little,

    Article is updated. Thanks :)

    1
    Comment actions Permalink
  • Avatar
    Andy Little

    Great support. Thanks Francisco Garcia :)

    0
    Comment actions Permalink
  • Avatar
    Malcolm.Allen

    After trying many different "fixes" found on the web, this one actually worked. Thank you!!

    0
    Comment actions Permalink
  • Avatar
    Chux Uzoeto (Edited )

    This keeps breaking some of my websites whenever there is a new update of plesk, and this manual solution is no real solution.  How can we fix this permanently ?  

    Reproduced that behavior and it's explained here: [BUG] Wordpress pages shows 404 not found error if FPM application served by nginx and Proxy Mode enabled

    Francisco Garcia, I was excited to read that there is a deeper explanation of why this happens and how to fix it.  However, the URL you linked (as above) is dead now.   Please, can you update the link to this bug you mention ... 

    For anyone else trying to gain clear insight into how nginx & apache work together in plesk-land, I found the following links useful:

     

    Thanks in advance.

    0
    Comment actions Permalink
  • Avatar
    Francisco Garcia

    Hi Chux Uzoeto,

    I don't consider necessary to recover this article since the bug PPPM-11234 was already fixed in Obsidian early versions and the workaround for that bug is the same as described here in this article https://support.plesk.com/hc/en-us/articles/213912945.

    0
    Comment actions Permalink
  • Avatar
    Chux Uzoeto

    Thanks, @Francisco Garcia ... I understand. 

    My problem is that even the solution you linked to for Obisidian is exactly the same fix that breaks each update.  

    What's the use of a control panel like Plesk that one has to pay for, if after every update many of your sites are broken and you have to manually fix them.

    This is a known issue that has persisted across versions of Plesk and for seemingly many years.  Why is Plesk refusing to find a permanent solution for this problem?  Taking consumers for granted?  

    This problem is making me seriously consider ditching plesk and seeking out an alternative.  

    0
    Comment actions Permalink
  • Avatar
    Francisco Garcia

    Hi Chux Uzoeto,

    If this issue is coming back to you on every update, I recommend you to open a support request.

    This is the only way to improve our product and to find out why it still happens to you after every update.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request