On October 19, 2021, we have enabled single-sign-on for our Plesk Support Center to provide a seamless login/account experience. This implies that you’ll be able to use a single account across any of our web-facing properties.
If you had already registered your account at Plesk 360 (formerly known as My Plesk) please use one for login. Otherwise please re-register it using the same email address as your existing Zendesk login (support account). It’s essential that you use the same email address on our support center to ensure that your tickets stay attached to the same account.

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
    Peter Luit

    Well, since I am not the admin on the highest level in Plesk, I cannot modify any settings to make a WordPres site run under Nginx. Is there any other way to do this?

    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
  • 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
  • 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
    Robert Asilbekov

    @Jeff  As far as I understand analyzer does not like ~ in location. According to nginx docs "...the “~” modifier (for case-sensitive matching). To find location matching a given request, nginx first checks locations defined using the prefix strings (prefix locations)."

    You may remove "~" it should not affect performance. As for other options, I see no problems. Moreover, the same sample is provided by Nginx and WordPress. However, it would be great if you may suggest a better option to build an ideal regex.

     

    0
    Comment actions Permalink
  • Avatar
    Allen

    This is the HTACCESS config.

    [content of the apache configuration file has been removed]

    0
    Comment actions Permalink
  • Avatar
    DoSieci.pl (Edited )

    its doesnt work...after rebuild pages still show 404 on wordpress pages. also i have this custom template before and it stop working after upgrade plesk!

    0
    Comment actions Permalink
  • Avatar
    Jonas Klinker

    How can I add the rule for each subdirectory for wordpress multiside?

    i.e.: domain is "example.de" and there should be a second wordpress installation in "example.de/test", how can I add the rule to this domain while having "example.de" still working?

    When I add the rule for ../test to the nginx-settings for example.de like:

    if ($test = PC) {
    rewrite ^/(.*)$ /index.php?$1;

    rewrite ^/(.*)$ /test/index.php?$1;

    }

    It will work on subdomain, but the main domain isnt working anymore..

    Thanks for your help!

    0
    Comment actions Permalink
  • Avatar
    Francisco Roman Garcia Rodriguez

    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
    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
    Alexander Tsmokalyuk

    Jonas,

    Please make sure you haven't specified "text/html" type in Additional nginx directives. This type is included by default and should not be specified explicitly.

    0
    Comment actions Permalink
  • Avatar
    Jeff Carter

    My nginx config analysis warns that the prescribed replacement:

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

    Does not have an ideal regex pattern.....

    "Regex location has no regex pattern
    Regex location has a valid modifier, but does not have a regex pattern.
    Performance-wise it is more efficient to configure exact or prefix matching for locations that do not require regex matching. It is also less prone to errors. Please refer to the documentation describing location directive to learn more."


    "Regex location has no anchors in regex pattern
    Regex location has a regex pattern without ^ or $. This is a configuration style that is prone to errors. It may also lead to a situation when requests partially matching the regex pattern are incorrectly routed to this location.
    Always use ^ or $ achor in a regex pattern."

    Given this advice, should that location directive be modified?

     

     

     

    0
    Comment actions Permalink
  • Avatar
    Artyom Volov

    Hello @Boun Vilailath,

    This is expected the behavior of default Plain permalinks in WordPress.

    If it is required that Permalinks display ID without questions mark, I suggest using Custom Structure for Permalinks.

    To do that:
    1. WordPress Dashboard > Settings > Permalinks.
    2. Select Custom Structure.
    3. Select "/%post_id%/".
    4. Click Save Changes.
    where you can select "/%post_id%/".

    In this case, URL will be displayed without the mark:
    example.com/wordpress/1/#comments

    0
    Comment actions Permalink
  • Avatar
    Konstantin Annikov (Edited )

    @Allen
    Could you please clarify your question? Am I right that htaccess files are not working for the website?
    If so, please check that php is being processed by Apache under Plesk > Domains > example.com > PHP Settings .
    In case the handler has been switched to 'FPM served by nginx', htaccess files are ignored. This is how nginx works.

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    @Marcin, thank you for letting us know about the issue.

    To resolve the issue with Nginx configuration compatibility with WP Rocket, consider contacting WP Rocket Support.

    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
    Jeff Carter

    Yes, my question really boils down to which new configuration the article should advise:

    1. location / {

    (Which essentially removes the regex)

    or

    2. location ~ /$ {

    (Which correctly anchors the general regex pattern)

    It does seem that the WordPress Codex recommends #1.  Is there agreement then?

    0
    Comment actions Permalink
  • Avatar
    Ion Iacob

    My sites with wordpress give error 500. Where and how can we see the error? Only when I delete all the themes of the wordpress allows me to access wp-login.php, but when installing a theme the site breaks again.

    0
    Comment actions Permalink
  • Avatar
    Andy Little

    Great support. Thanks Francisco Roman Garcia Rodriguez :)

    0
    Comment actions Permalink
  • Avatar
    Andy Little

    Hi Francisco Roman Garcia Rodriguez,

    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
    Andy Little

    Hi Francisco Roman Garcia Rodriguez,

    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
    Marcos Paulino Chahin

    On both a new and old plesk onyx server using web host, we get this:

     

    Error: phpinimng failed: Unable to update the config file for 'fpm' service due to syntax errors.

     

    When we add the directives to a single website.  Any ideas why?

    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 Roman Garcia Rodriguez, 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
    Ivan Postnikov

    Hello Koray Snoray

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

    0
    Comment actions Permalink
  • Avatar
    Denis Bykov (Edited )

    @Jonas Klinker
    According to WordPress blog page, correct Nginx rewrite rules for a subdirectory multisite setup are following:

    location ~ ^(/[^/]+/)?files/(.+) {
    try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
    access_log off; log_not_found off; expires max;
    }

    location ^~ /blogs.dir {
    internal;
    alias /var/www/example.com/htdocs/wp-content/blogs.dir ;
    access_log off; log_not_found off; expires max;
    }

    if (!-e $request_filename) {
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    rewrite ^(/[^/]+)?(/wp-.*) $2 last;
    rewrite ^(/[^/]+)?(/.*\.php) $2 last;
    }

    location / {
    try_files $uri $uri/ /index.php?$args ;
    }

    location ~ \.php$ {
    try_files $uri =404;
    include fastcgi_params;
    fastcgi_pass php;
    }


    Refer to the following page for more information: https://codex.wordpress.org/Nginx

    0
    Comment actions Permalink
  • Avatar
    Lindsay Adamson

    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

Please sign in to leave a comment.

Have more questions? Submit a request