Ability to customize nginx per site template e.g. Location /, Location ~, etc
Hello, I'm using Plesk Onyx and I've also bumped into problems with not being able to set correct NGINX Directives.
Regarding nginx and nginx configuration for various CMS, Web Apps etc, I see that a lot of directives need to be set and there are a lot of scattered issues around in the web.
For example most CMS will require a
location / { ... }
or for google's pagespeed test we need to add expire headers e.g.
location ~* .*.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 14d;
}
I think the Model to building the final vhost conf file should be revised instead of focusing on specific use cases like "Duplicate Location / {} directives".
If we simplify it, the current model works like that:
The Plesk vhost template for NGINX reads some database values and then appends specific directives using variables regarding the domain.
Afterwards it includes the custom vhost_nginx.conf file at each server {...} directive declaration.
So since some records are already defined, the originals match before our own directives so our directives are ignored or our directives turn out as duplicates.
I can think of 3 different suggestions instead in this case.
1. Add the ability to set a custom base vhost template for each vhost separately
In this case:
- The vhost is created by PLESK using the default template.
- The user would then be able to clone the original template and modify to their needs
- The modified template would be saved either to the db or to a separate file
- If a modified template exists -> the system would use that one instead of the PLESK default one to build the final last_nginx.conf file.
- Keep only minimal required vhost configuration information in the base template and add the rest to db so that people can then easily override for their custom vhost configuration. In this case:
- Separate Location / {} directives from the rest, including location / { proxypass https://{IP}:{PORT}; proxysetheader Host $host; proxysetheader X-Real-IP $remoteaddr; proxysetheader X-Forwarded-For $proxyaddxforwardedfor; access_log off; } etc ...
- The vhost is created by PLESK using the default template which does not include any location directives.
- When the user chooses to use nginx the additional nginx directives field is populated by what would be generated by the template on save with some comment that removing this could result in his site not working.
Add a reset button to reset to initial configuration if the user messes up.
Similar to 2 but use 2 fields to store the information.
One field is a checkbox to enable or disable plesk's directives with a warning that the site might not load correctly.
A field to add custom directives so that the user can input his own configuration.
There should be a box or button to display the recommended configuration for the vhost
A reset button to the recommended configuration would be nice.
Let me know if you think something like this is achievable or why it can't be done. Thanks in advance for your efforts.
Thank you for your input! We will consider these nginx configuration suggestions in upcoming releases if it will be popular.
Everyone, please continue voting for this feature and add your comments if you consider it important.
—
IG
-
Gabriel T commented
The worst part about this issue is that you're also unable to use HTTP/2 with this bug because it relies on nginx with SSL. This is going to make plesk obsolete pretty soon. I wish this would be given priority within this year otherwise our company has decided to plan a migration to CPanel for next year.
-
Serban Cristian commented
Why hasn't this been implemented already?
Without this, nginx is almost useless for lots of cms'es, including xenforo with which i have huge issues because of plesk inability to allow us make one simply adjustment to the `location / {}` block.I have a support ticket with plesk and your attitude towards this issue is miserable. This is clearly something people need, but still you are ignoring the request and send us all to this **** form to vote for something that might never be implemented.
-
CSS commented
I think Plesk should protect user with no nginx experienced by only provide "fixed options" of couple of popular CMS vhost template.
Only more advanced users are allowed to add their own vhost profile/template. They should use command line to add new vhost profile / template themself.
-
CSS commented
I think Plesk should have a dropdown vhost profile selection when user add a domain. User then can add their own vhost template (via command line or GUI) , Look at VestaCP theiy already has this function.
I found this post after I post my thread https://plesk.uservoice.com/forums/184549-feature-suggestions/suggestions/19440022-plesk-should-support-popular-cms-nginx-vhost
-
Gabriel T commented
I've been thinking about this and there's another way to approach this solution too. Some special tags could be implemented so that when the final vhosts is completed some additional tasks are also executed like, MERGE/REPLACE/DELETE
For example
location / {PLESK_DELETE
try_files ...
} -> Delete all directives matching location / and then write current location directivelocation ~* \.*.(jpg|jpeg|png|gif|ico|css|js)$ {PLESK_MERGE
expires 14d;
} --> If location directive exists then append expires 14d to the location block; else write current location directivelocation / {PLESK_DELETE} --> remove directives matching location / before adding other directives.
Order of execution could be
1. PLESK_DELETE
2. PLESK_REPLACE
3. PLESK_MERGE -
Gabriel T commented
I've noticed that In addition to this point there is also another problematic location directive .
location ~ /$ {
<?php echo $VAR->domain->physicalHosting->proxySettings['directoryIndex'] ?>
}can cause urls in the form of http://www.domain.com/path/ to yield 404 while http://www.domain.com/path is OK for CMS pages.
-
Matthias commented
I would love to add my voice to this. Not being able to correctly use nginx makes it almost useless.
-
Gab T commented
I think this is a serious problem because it can cause an issue even with a simple magento e-shop install. Especially for people not really experienced with nginx that try to implement instructions from the official kb from these apps.
-
Levi Meahan commented
7 months so far this still isn't in - Very annoying when trying to configure Nginx as a reverse proxy server for Node apps. Quite frustrating to have to use a hack-ish workaround for a functionality that is so core to setting up a Node project behind Nginx.
-
scysys commented
It´s not really important. It´s not hard to resolve this with own config files, but it would be better when Plesk automatically prevent such errors.
-
David Wieler commented
Thanks Simon. That solution you linked to doesn't work on Node/Express apps.
-
Simon commented
We really need this to support Symfony and Laravel projects.
We have found a workaround but it does not work on every project !!
-
Reinhard Hutter commented
Plesk 12 comes with a default
location / {
...
}
directive in the nginx config file. This is really bad because very many prominent PHP applications and frameworks (e.g. Symonfy 2) ship with setup instructions containing a
location / { ... }
directive themself, leading to "duplicate location" errors when adding those directives in "Additional nginx directives"