New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: custom try_files on Nginx #461

Closed
negrusti opened this Issue Jul 12, 2017 · 12 comments

Comments

Projects
None yet
5 participants
@negrusti
Contributor

negrusti commented Jul 12, 2017

Most of WordPress static caching plugins require modifications of try_files for root location.
It seems at present there is no possibility to achieve this in Froxlor.
Perhaps just a switch "do not generate default try_files", and then merging custom try_files directive from domain specialsettings will be sufficient.
Sample configurations:
Cache Enabler -
https://www.keycdn.com/support/wordpress-cache-enabler-plugin/
WP Super Cache -
https://codex.wordpress.org/Nginx#WP_Super_Cache_Rules
W3TC -
https://codex.wordpress.org/Nginx#W3_Total_Cache_Rules

@EricReiche

This comment has been minimized.

Show comment
Hide comment
@EricReiche

EricReiche Jan 1, 2018

I just wanted to push this.
Before switching to Nginx I assumed that I can use the custom domain configs for that, but now realized that it's impossible. Lots of PHP scripts out there use different rewrite strategies for nice URLs.

EricReiche commented Jan 1, 2018

I just wanted to push this.
Before switching to Nginx I assumed that I can use the custom domain configs for that, but now realized that it's impossible. Lots of PHP scripts out there use different rewrite strategies for nice URLs.

@negrusti

This comment has been minimized.

Show comment
Hide comment
@negrusti

negrusti Jan 11, 2018

Contributor

I am not sure what the best approach is.
One option is to add a field "try_files" to domains table, default value 1, and then add another condition in
/scripts/jobs/cron_tasks.inc.http.30.nginx.php
if ($domain['phpenabled_customer'] == 1 && $domain['phpenabled_vhost'] == '1') { $webroot_text .= "\t" . 'index index.php index.html index.htm;' . "\n"; $webroot_text .= "\t\t" . 'try_files $uri $uri/ @rewrites;' . "\n"; } else { $webroot_text .= "\t" . 'index index.html index.htm;' . "\n"; }
change to
if ($domain['phpenabled_customer'] == 1 && $domain['phpenabled_vhost'] == '1' && $domain['try_files'] == 1) { $webroot_text .= "\t" . 'index index.php index.html index.htm;' . "\n"; $webroot_text .= "\t\t" . 'try_files $uri $uri/ @rewrites;' . "\n"; } else { $webroot_text .= "\t" . 'index index.html index.htm;' . "\n"; }

Another one is to add a special condition for try_files into mergeVhostCustom, but I think it will be ugly.

Yet another option is to skip adding try_files if $domain['specialsettings'] is not empty. Very easy to implement, but will break existing setups with custom vhost configs.

Contributor

negrusti commented Jan 11, 2018

I am not sure what the best approach is.
One option is to add a field "try_files" to domains table, default value 1, and then add another condition in
/scripts/jobs/cron_tasks.inc.http.30.nginx.php
if ($domain['phpenabled_customer'] == 1 && $domain['phpenabled_vhost'] == '1') { $webroot_text .= "\t" . 'index index.php index.html index.htm;' . "\n"; $webroot_text .= "\t\t" . 'try_files $uri $uri/ @rewrites;' . "\n"; } else { $webroot_text .= "\t" . 'index index.html index.htm;' . "\n"; }
change to
if ($domain['phpenabled_customer'] == 1 && $domain['phpenabled_vhost'] == '1' && $domain['try_files'] == 1) { $webroot_text .= "\t" . 'index index.php index.html index.htm;' . "\n"; $webroot_text .= "\t\t" . 'try_files $uri $uri/ @rewrites;' . "\n"; } else { $webroot_text .= "\t" . 'index index.html index.htm;' . "\n"; }

Another one is to add a special condition for try_files into mergeVhostCustom, but I think it will be ugly.

Yet another option is to skip adding try_files if $domain['specialsettings'] is not empty. Very easy to implement, but will break existing setups with custom vhost configs.

@EricReiche

This comment has been minimized.

Show comment
Hide comment
@EricReiche

EricReiche Jan 11, 2018

Maybe add a try_files domain attribute to the webinterface which overwrites default config if not empty.

EricReiche commented Jan 11, 2018

Maybe add a try_files domain attribute to the webinterface which overwrites default config if not empty.

@d00p

This comment has been minimized.

Show comment
Hide comment
@d00p

d00p Jan 11, 2018

Member

Theres always the "specialsettings" field per.domain to add custom content. @negrusti is right, it should Just be possible to disable the automatically generated try_files entry

Member

d00p commented Jan 11, 2018

Theres always the "specialsettings" field per.domain to add custom content. @negrusti is right, it should Just be possible to disable the automatically generated try_files entry

@negrusti

This comment has been minimized.

Show comment
Hide comment
@negrusti

negrusti Jan 11, 2018

Contributor

You mean keep the actual try_files string in that field? Could be too

Contributor

negrusti commented Jan 11, 2018

You mean keep the actual try_files string in that field? Could be too

@kezenwa

This comment has been minimized.

Show comment
Hide comment
@kezenwa

kezenwa Feb 2, 2018

Hi All, Please I want to know how current FROXLOR users are able to host WordPress websites on NGINX.

I asked this question in FROXLOR forum but has gotten no response. I want to know how current FROXLOR users are able to host wordpress websites and some other PHP websites on NGINX webserver .
My machine configuration are :
CENTOS 7 + NGINX + PHP-FPM + PHP7.1

Waiting for urgent response

kezenwa commented Feb 2, 2018

Hi All, Please I want to know how current FROXLOR users are able to host WordPress websites on NGINX.

I asked this question in FROXLOR forum but has gotten no response. I want to know how current FROXLOR users are able to host wordpress websites and some other PHP websites on NGINX webserver .
My machine configuration are :
CENTOS 7 + NGINX + PHP-FPM + PHP7.1

Waiting for urgent response

@negrusti

This comment has been minimized.

Show comment
Hide comment
@negrusti

negrusti Feb 2, 2018

Contributor

I do it like this:
https://gitlab.com/negrusti/Froxlor/compare/master...try_files?view=inline
So if there are any special vhost settings present, default try_files won't be generated.
Please note that it will break all existing vhosts with special settings - you will need to add try_files manually to them.

Contributor

negrusti commented Feb 2, 2018

I do it like this:
https://gitlab.com/negrusti/Froxlor/compare/master...try_files?view=inline
So if there are any special vhost settings present, default try_files won't be generated.
Please note that it will break all existing vhosts with special settings - you will need to add try_files manually to them.

@kezenwa

This comment has been minimized.

Show comment
Hide comment
@kezenwa

kezenwa Feb 2, 2018

@negrusti
Is this an Update or what ?
How do I apply it - download new FROXLOR from froxlor.org OR from Github ?

I last downloaded FROXLOR 1 Month ago .
Please do let me know if this is an official Update or a Patch so at least I know what to do.

Also is this how most FROXLOR users are able to host PHP enabled websites such as WordPress on NGINX + PHP-FPM ?

Thanks for your help

kezenwa commented Feb 2, 2018

@negrusti
Is this an Update or what ?
How do I apply it - download new FROXLOR from froxlor.org OR from Github ?

I last downloaded FROXLOR 1 Month ago .
Please do let me know if this is an official Update or a Patch so at least I know what to do.

Also is this how most FROXLOR users are able to host PHP enabled websites such as WordPress on NGINX + PHP-FPM ?

Thanks for your help

@kezenwa

This comment has been minimized.

Show comment
Hide comment
@kezenwa

kezenwa Feb 2, 2018

To apply the above suggestion, do I download a new FROXLOR from FROXLOR website or from Github ?

Also any way to stop FROXLOR from deleting the default "www.conf" File in "/etc/php-fpm.d folder ?

kezenwa commented Feb 2, 2018

To apply the above suggestion, do I download a new FROXLOR from FROXLOR website or from Github ?

Also any way to stop FROXLOR from deleting the default "www.conf" File in "/etc/php-fpm.d folder ?

@d00p

This comment has been minimized.

Show comment
Hide comment
@d00p

d00p Feb 3, 2018

Member

@kezenwa this is not our support forum.

Member

d00p commented Feb 3, 2018

@kezenwa this is not our support forum.

@schnuffle

This comment has been minimized.

Show comment
Hide comment
@schnuffle

schnuffle Feb 10, 2018

+1
I'm using a nearly similar patch to be able to customize the try_files directive for the / location.
For people that do not dive into code it might be a good idea that there's a flag activating special settings which introduces the try_files block into the special settings at first creation.
Afterwards it can be customized.

Regards

Schnuffle

schnuffle commented Feb 10, 2018

+1
I'm using a nearly similar patch to be able to customize the try_files directive for the / location.
For people that do not dive into code it might be a good idea that there's a flag activating special settings which introduces the try_files block into the special settings at first creation.
Afterwards it can be customized.

Regards

Schnuffle

@d00p d00p closed this in 372ab5d Feb 13, 2018

@negrusti

This comment has been minimized.

Show comment
Hide comment
@negrusti

negrusti Feb 13, 2018

Contributor

Many thanks!

Contributor

negrusti commented Feb 13, 2018

Many thanks!

Logicbloke added a commit to Logicbloke/Froxlor that referenced this issue Feb 15, 2018

add domain flag to avoid generation of nginx try_files directive in w…
…ebroot which is not suitable for some applications; fixes #461

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment