I put these directives into htaccess in the domain root
after disabling Nginx (in Tools & Settings / Services)
These are directives suggested by WP for network configuration after a new installation.
Code:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
Now I see
both the Home Page (of the main domain and the mapped domain) and
both pages "Hello World".
By converting these directives to Nginx I get this code:
Code:
#ignored: "-" thing used or unknown variable in regex/rew
rewrite ^/wp-admin$ /wp-admin/ permanent;
if (-f $request_filename){
set $rule_2 1;
}
if (-d $request_filename){
set $rule_2 1;
}
if ($rule_2 = "1"){
#ignored: "-" thing used or unknown variable in regex/rew
}
rewrite ^/(wp-(content|admin|includes).*) /$1 last;
rewrite ^/(.*\.php)$ /$1 last;
rewrite /. /index.php last;
With Nginx active and with these directives I see:
The Home page and the "Hello World" page of the main domain;
The Home Page of mapped domain and
Error 404 for the "Hello World" page of mapped domain.
However, I would like to make some considerations:
- I've totally read these guides: Getting starting, Admin's Guide, Customer's Guide, Reseller's Guide, Advanced Admin's Guide for Linux, Reference for Command Line.
- I've also read dozens of Internet pages about Nginx, WP and WP on Nginx.
- I've also read dozens of threads on this forum, the WP forum and others like "Stackoverflow".
- The NGinx forum is a useless thing: there's a lot of unanswered questions.
Now, probably I'm not configuring Plesk and Nginx well, but I can not become an expert in a short time.
For this reason, I would like to ask for help by expressly declaring myself "Newbie".
From all this reading I came to these conclusions (maybe wrong):
- I have only one static IP and so I have created only one Unlimited subscription.
- On this server (and in this subscription) there are several domains that are associated (or will be associated) with different applications: CMS like Joomla, Blogs in WP, ECommerce, Moodle, CRM, ...
- So the server and subscription configurations should remain as general as possible, while at the domain level I have to apply more specific directives.
In
Appendix A: Web Server Configuration Files there is very clear documentation that all Nginx configurations are handled automatically, except the first (at server level) and the last (at domain level).
But, if I did not read it wrong, the file
/var/www/vhosts/system/_<domain_name>/conf/last_httpd.conf is still refers to the previous configurations.
This puts me in great difficulty doing the tests because on Internet there are examples that refer to a single "global" configuration and not a multi-level configuration like in Plesk.
Furthermore, I have not been able to disable Nginx at domain level because with the command "
plesk bin subscription --update-web-server-settings MY-DOMAIN -nginx-transparent-mode true" I always see a Nginx error 404.
In fact, to take the test I had to block the entire service (so blocking all other domains).
In Domain Settings I have filtered the Apache / Nginx Error logs, but I do not see any errors.
Also, the file
/var/log/nginx/error.log has the "zero" length.
Concluding, what I would like to know is:
- How can I maintain a granularity of configurations for each domain so that it is possible to use specific directives for each server application?
- How can I disable Nginx at a single domain level working with Apache, while for all other domains continue to use the Reverse Proxy?
- Obviously, how should htaccess directives be converted and where should they go?
- Having domains mapped to WP, should I always configure Nginx for Wildcard Subdomains or do I need only the main domain configuration?
Many thanks again for the help, the comprehension and the patience.