I've written a script to copy my modified file back into /var/www/vhosts/system/site.com/conf/
I see no reason for plesk to be overwriting the file constantly. for whatever changes it should be possible to parse the file for the lines plesk needs to change and change only those lines.
Thanks,
Curtis
@cmaurand
You can use Nginx custom templates that will stick across updates.
There is only one downside : you will get all kinds of annoying error notifications with updates and/or when using plesk repair command and/or when using or running httpdmng in general ............ but in most cases, these error notifications can safely be ignored.
You should use the following steps or commands :
1 - run : cd /opt/psa/admin/conf/templates
2 - cd into the default directory and have a look at the subdirectories and the nginx[..].php files : these files are used to (re-)generate Nginx config files
3 - REMINDER : NEVER change the files / directories in /opt/psa/admin/conf/templates/default directory !!!
4 - if you need to have a custom Nginx config at the [z] level (with z being one of "domain", "server", "service" and "webmail"), then :
4.1 - run : cd /opt/psa/admin/conf/templates/default
4.2 - traverse through the config generation files (in the default directory) and select the one that you need
4.3 - set config file var - run : file="string" (with string being the config file name, only the name)
4.4 - set base directory file var - run : level="string" (with the string being one of "domain", "domain/service", "server", "service" and "webmail")
NOTE : one should - in general - not have any need to customize the php files in the default directory, so it is assumed that you need the var $level
4.5 - run : cd /opt/psa/admin/conf/templates && mkdir custom
NOTE : it is recommended to first use a test directory first and move the finished contents of the test directory to the custom directory afterwards!!
4.6 - run : cd custom && mkdir -p $level
4.7 - run : cd ../
4.8 - copy default file to custom directory - run : cp "default/$level/$file" "custom/$level/$file"
4.9 - run : cd "custom/$level/"
4.10 - change the file as desired, but ADD the custom contents to the file : do not remove the original contents and/or minimize the changes thereof
NOTE : in some cases, it is necessary to remove the original contents or a huge part of it, but that is not safe in Plesk environments - think of other solutions!
NOTE : one should - in theory - be able to save the customized files under any name, but it is easier to keep the default name - this facilitates comparison!
5 - REMINDER : thoroughly TEST the customization and
5.1 - do a PHP validity check - run : php -l <file-name> (to test whether the custom config file is a valid PHP file)
5.2 - run a test of auto-regeneration on ONE domain - run : httpdmng --reconfigure-domain <test domain>
and run the new test domain in a test environment, so you can tweak the config customization if and where necessary.
6 - REMINDER : ONLY customize one file at a time, otherwise the Plesk behavior can become fairly unpredictable.
7 - check the GENERATED custom config in the test domain : have a look at the contents of /etc/nginx/plesk.conf.d/vhosts/<test domain>.conf
NOTE : only move the custom configuration to production environments if they are working properly and tested properly
Sure, the above contains a number of steps that can be shortened, but it is just an illustration that aims to make "foolish errors" less likely.
Everybody should take the steps required and as they seem fit and comfortable.
As a general remark, it should be duly noted that
a) Nginx config customization will apply to ALL domains that are hosted on the server and that are using the config generation templates
b) some domains hosted will require custom adjustments, so please do not use custom templates for that purpose
c) some adjustments should be kept simple ....... a simple Nginx rewrite on the domain level often will suffice!
It might be the case that point c) applies to your scenario, since you essentially want to remove the strings added to the URL - or am I mistaken?
In short, there is no need for a script, there is only a possibility of a persistent change in config regeneration with customized templates.
Have a look at :
-
Changing Virtual Hosts Settings Using Configuration Templates
-
Appendix A: Configuration Templates Structure
and I hope the above helps a bit to replace your script!
Kind regards....
PS As usual, one can even add php ini files to the customized config - quite handy when requiring some fixed variables, but in practice it is often more easy to hard-code value (not variables) in the config generation templates!