• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Plesk adds nginx directives on its own... cannot clean nginx conf files

PaulS8

New Pleskian
Hi all,

I have a problem with one host rewrite directive that is added by Plesk automatically every time when I reconfigure that host. This is the directive being added:

Code:
    if ($host ~* ^www.mysite.com$) {
        rewrite ^(.*)$ http://mysite.com$1 permanent;
    }

This coded is added to the automatically generated last_nginx.conf every time when I run

Code:
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain <mysite.com>

So, I drilled down to /etc/nginx/plesk.conf.d/vhosts and tried to edit that host conf file, but it reverts back and the rewrite directive is added again after reconfiguring the domain with httpdmng.

The vhost.conf file is empty (the one under /var/www/vhosts/system/mysite.com/conf). Also there is nothing in Web Server Settings for that domain - the nginx directives' window is empty.

How can I fix this and get rid of that rewrite directive? I have no ideas as where it comes from.....
 
Hi PaulS8,

webserver - configuration files are created from the template folder "/usr/local/psa/admin/conf/templates/default". Please create own ( modified ) templates by adding a "custom" folder with the files and modifications, which should contain your very own, specific configurations. Please see the Plesk documentation for it:


In your case, you find the definitions at "/opt/psa/admin/conf/templates/default/domain/service" in the template "nginxSeoSafeRedirects.php"
 
Thanks UFHH01,

I followed the instructions, cloned all "default" templates to a new "custom" folder and commented all lines in the templates "nginxSeoSafeRedirects.php" and "seoSafeRedirects.php". Now it works fine, but it is just a temporary solution, because wrong redirect settings for that domain are still saved somewhere.

In the template files these settings are revoked as

Code:
$VAR->domain->isSeoRedirectToWww

Where is that "isSeoRedirectToWww" constant saved? To fix the problem permanently, I have to find that file and erase "isSeoRedirectToWww" for that domain.
 
Last edited:
Hi PaulS8,

it was a bad idea to clone ALL templates. You now never will receive any updates/upgrades/patches for ALL templates, because Plesk never overwrites files in the custom folder. You should consider to overthink your modifications, in order to keep your system up-to-date.

The setting "SeoRedirect" is saved in the psa database ( dom_param ).
 
All good, thank you UFHH01 - I've deleted that "seoRedirect" record from the psa database and everything works as it should. I still have no ideas as how "seoRedirect" appeared in the database. The site migrated from another server using Plesk migration manager. Somehow it added the redirect setting.
 
Back
Top