• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

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