HI, I thought this might come in handy for anyone looking to use Short URL's with Nginx on PLesk Control Panel
( this is only for someone wanting to run FPM application served by Nginx )
my setup is CentOS 7 with PLesk Obsidian Control Panel
in PLesk there is setting to add additional nginx directives, it's located under > Apache & Nginx Settings.
Additional nginx directives
Here you can specify the settings for the nginx reverse proxy server that runs in front of Apache. Your directives will override the server-wide nginx configuration. For example, you may want to change the connection timeout or to pack requests with gzip. Use the same syntax as you use for nginx.conf. For example, if you want to pack all the proxied requests with gzip, add the line: 'gzip_proxied any;'.Additional nginx directives
I added this rewrite code below and now its working ( I have Snapshots of the settings below also, and where you add the rewrite code for short url's to work with Nginx for phpFox in PLesk control Panel . It's working great with phpFox version 4.7.8 and should be backward compatible to work with version 4.6.0 and up
UPDATE 04/28/2020
the issue is a bug of Plesk, so if you try to add the additional directive below without doing the steps below you will get the error. so follow the steps and you will not get an error :)
Latest Plesk Obsidian : if trying to add this directive and you receive an error: Unable to add "location /" to additional nginx directives for domain in Plesk: nginx: [emerg] duplicate location "/"
Using Plesk Obsidian :
- OS: CentOS Linux 7.7.1908 (Core)
- Product: Plesk Obsidian 18.0.26 last updated at April 24, 2020 01:17 PM
- In order to get this to work without ERRORS
-
Alternatively disable proxy mode and only nginx will be serving requests on domain:
-
1) Log into Plesk;
-
2) In Domains > example.com > Apache & nginx directives temporary remove additional nginx directive containing
location /
; -
3) Disable Proxy Mode, Under Nginx Settings de-select the check mark and click Apply;
-
4) Then Insert the below necessary directive back into Additional nginx directives and click Apply.
if (!-e $request_filename){
rewrite ^(.*)$ /index.php break;
}
location / {
rewrite ^/file/(.*) /PF.Base/file/$1 last;
rewrite ^/static/ajax.php /index.php last;
rewrite ^/themes/default/(.*) /PF.Base/theme/default/$1 last;
rewrite ^/(static|theme|module)/(.*) /PF.Base/$1/$2 last;
rewrite ^/(Apps|themes)/(.*) /PF.Site/$1/$2 last;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /PF.Base/file/log {
deny all;
return 404;
}
Here are my photos so you can see how the settings look in PLesk - last photo is where I've added the rewrite code and got short URL's working on mysite :)
The last Photo is where I added the rewrite code for phpFox to work with Nginx in Plesk
Click Apply and your all Done.
then go back to AdminCP and click on Short URL's.
if it says can't read .htaccess file, you need to manually turn on this feature
FTP to your public_html folder and open the file
PF.Base / file / settings / server.sett.php
and look for
$_CONF['core.url_rewrite'] = '2';
and replace that with
$_CONF['core.url_rewrite'] = '1';
By setting this to "1" this will transform your sites URLs from (example's below):
https://www.yoursite.com/index.php?do=/blog
to
https://www.yoursite.com/blog
Save and close the file.
You should now have short url's enabled on your site.
Hope this Helps someone who may require to run phpFox Short URLS with Nginx on Plesk Control Panel
Warm Regards,
Spiro G