• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Double Listen directives

WhiteTiger

Basic Pleskian
Forgive me the newbie questions,

In the /etc/nginx/plesk.conf.d/server.conf I see two listen directives
  • listen My-IP-Address:80;
  • listen My-IP-Address:443 ssl;
and in the /var/www/vhosts/system/MyAccount/conf/nginx_ip_default.conf I see other two listen directives:
  • listen My-IP-Address:443 default_server ssl http2;
  • listen My-IP-Address:80 default_server;
Why?
And is it correct that a file called with include redefines the directives present in the calling file?

I wonder what directive has priority.
  1. server.conf calls nginx_ip_default.conf
  2. In nginx_ip_default.conf there are the server blocks with location directives
  3. In server.conf, after the include, there are other server blocks with other definitions of locations
All these files are "GENERATED AUTOMATICALLY".
What creates these files?
 
Hi WhiteTiger,

these files are correctly setup with the help of "webserver configuration templates" ( => /usr/local/psa/admin/conf/templates/default / => Appendix B: Configuration Templates Structure ).

"server.conf" is the nginx configuration file just for your IP(s), while your "nginx_ip_default.conf" ( or "nginx.conf" and the optional "vhost_nginx.conf" ) defines your (sub)domain - specific configuration(s).

server.conf calls nginx_ip_default.conf
It doesn't call the (sub)domain - specific configuration file, it INCLUDES the (sub)domain - specific configurations, setup over your Plesk Control Panel for your (sub)domain(s). ;)

What creates these files?
Each modification ( IP or (sub)domain - dependent ) or changes related to your webserer ( apache + nginx + PHP ) over your Plesk Control Panel result in a creation of these ( dependent ) configuration files.


Pls. consider to use the SEARCH option at => Documentation and Help Portal for Plesk to inform yourself about Plesk, it's components, features and options. The documentation is huge and written for professionals AND non-professionals, so that it is very easy to understand for everyone. It even exist in different languages ( some parts... not all though! ). :)
 
I've read dozens of Plesk, Nginx, and Wordpress documents, official and no, without ending anything.

I should define some configurations "server + listen + location".
I can not do this in the two primary conf files because they are created automatically.
I should (perhaps) put them in the panel Apache and Nginx Settings , but it is include at the end of the nginx_ip_default.conf.

Which means that, first, is defined the default_server created by Plesk in nginx_ip_default.conf; then the default_server defined by me and finally the server still defined by Plesk in server.conf.

But the documentation says that only the first definition is considered.
 
I read (again) the Plesk documentation (admin and advanced).
I did not find any information that could help me solve the problem.

All Nginx Wordpress configuration suggestions that I found in Internet require configuration of "Server + location" blocks, but these can not be inserted into the Nginx Settings in the Domain Panel.

Neither I can (nor I want) to modify templates in PHP.

My Wordpress configuration is: WP Multisite + subdomain + domain mapped + HTTPS.
The main domain is accessible both in Home Page and in articles.
Domain only reaches the Home Page, while items return a 404 Error.

Server: CentOS Linux 7.3.1611 (Core)
Plesk: Onyx Version 17.5.3 Update # 11
WP: Installed from Plesk, 4.8

Last Nginx Settings of the main domain panel there are:
Code:
       # enable gzip compression
       gzip on;
       gzip_min_length 1100;
       gzip_buffers 4 32k;
       gzip_types text/plain text/javascript application/javascript application/x-javascript text/xml text/css;
       gzip_vary on;
       # end gzip configuration
       location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
           expires max; log_not_found off;
       }

       # From WP Network Config (without errors from Plesk conversion)
       rewrite ^/wp-admin$ /wp-admin/ permanent;
       rewrite ^/(wp-(content|admin|includes).*) /$1 last;
       rewrite ^/(.*\.php)$ /$1 last;
       rewrite /. /index.php last;

Thanks in advance for any advice.
 
Hi WhiteTiger,

you have now ( finally ) included the necessary informations, which makes it possible to suggest solutions and work-arounds;
My Wordpress configuration is: WP Multisite + subdomain + domain mapped + HTTPS.

Pls. have a closer look at the official wordpress documentation, in case that you use NGINX:


As you can see, there are of course only examples without Plesk usage, so you now have to adapt these examples to the existing configuration(s) on your server!

Pls. note:

  • Examples like
    Code:
    map $http_host $blogid {
        default       -999;
    
        #Ref: http://wordpress.org/extend/plugins/nginx-helper/
        #include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ;
    
    }
    ... have to be put into the section "http"
    Code:
        http {
    ...
    ...
    ...
            include /etc/nginx/conf.d/*.conf;
        }
    of your /etc/nginx/nginx.conf and the additional Multisite configuration ( as for example )
    Code:
        location ^~ /blogs.dir {
            internal;
            alias /var/www/vhosts/YOUR-DOMAIN.COM/httpdocs/wp-content/blogs.dir ;
            expires max;
            }
    
        location ~ ^/files/(.*)$ {
            try_files /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1 ;
            expires max;
            }
    ... should be inserted into your "Additional NGINX directives" - box, at your (sub)domain settings inside of your "Apache and nginx settings".
  • Examples like
    Code:
        location / {
            try_files $uri $uri/ /index.php?$args ;
        }
    can' t be used, as the rewrite "location /" has already been setup when you use Plesk. For Wordpress Multisites, it is a well known fact, that you should use for example:
    Code:
        if (!-e $request_filename) {
                rewrite /wp-admin$ $scheme://$host$uri/ permanent;
                rewrite ^(/[^/]+)?(/wp-.*) $2 last;
                rewrite ^/[^/]+(/.*.php)$ $1 last;
            }
  • Examples like
    Code:
        location ~ \.php$ {
            try_files $uri =404;
            include fastcgi_params;
            fastcgi_pass php;
        }
    should be ignored, as they are already setup by Plesk ( depending to your PHP - handler usage! )

Code:
       # enable gzip compression
       gzip on;
       gzip_min_length 1100;
       gzip_buffers 4 32k;
       gzip_types text/plain text/javascript application/javascript application/x-javascript text/xml text/css;
       gzip_vary on;
       # end gzip configuration
Can ( and should be! ) setup at the "/etc/nginx/ngin.conf", so that this setting is used for all (sub)domains on your server. ;)


If you have further questions/issues/errors/problems, pls. don't forget to inform us with the help of corresponding - log - entries, as the enormous possible issues/errors/problems with nginx rewrites for wordpress are countless and always depend on YOUR VERY OWN settings, plugins usage and the existing configurations. So it wouldn't hurt, to include the (sub)domain - specific configuration files from "/var/www/vhosts/system/YOUR-DOMAIN.COM/conf", as we are not able to guess such things. :)
 
Nginx « WordPress Codex
I can assure you I read it, like many other reference pages on the Internet.

In Codex it is written:
This guide is referring to a standalone Nginx setup, where it is used as the primary server instead of Apache.
I'm a Reverse Proxy. Can this change the suggested configurations?

You suggested to make these changes on /etc/nginx/ngin.conf, but in Plesk there are many domains and some are associated with Joomla or Prestashop.So, tThese changes will also modify domains without WP.

Anyway here are the new files:

/etc/nginx/nginx.conf
Code:
#user  nginx;
worker_processes  1;

#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

#pid        /var/run/nginx.pid;

include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections  1024;
}

http {
   include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay        on;

    #gzip  on;
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server_tokens off;

   map $http_host $blogid {
    default       -999;

    #Ref: http://wordpress.org/extend/plugins/nginx-helper/
    #include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ;
    include /var/www/vhosts/MyAccount/httpdocs/My-WP-domain/wp-content/uploads/nginx-helper/map.conf;
   }

   include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

/var/www/vhost/system/MyAccount/conf/vhost_nginx.conf
Code:
# From talk.plesk.com
location ^~ /blogs.dir {
   internal;
   alias /var/www/vhosts/MyAccount/httpdocs/MyDomain/wp-content/blogs.dir ;
   expires max;
}

location ~ ^/files/(.*)$ {
   try_files /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1 ;
   expires max;
}

if (!-e $request_filename) {
   rewrite /wp-admin$ $scheme://$host$uri/ permanent;
   rewrite ^(/[^/]+)?(/wp-.*) $2 last;
   rewrite ^/[^/]+(/.*.php)$ $1 last;
}
# End From talk.plesk.com

# enable gzip compression
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain text/javascript application/javascript application/x-javascript text/xml text/css;
gzip_vary on;
# end gzip configuration
location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$
{
   expires max; log_not_found off;
}

# From WP Network Config (without errors from Plesk conversion)
#rewrite ^/wp-admin$ /wp-admin/ permanent;
#rewrite ^/(wp-(content|admin|includes).*) /$1 last;
#rewrite ^/(.*\.php)$ /$1 last;
#rewrite /. /index.php last;

With this code I see the Home Page of main domain ad second domain, but now I can no longer see the "Hello world" page of both domains.
Earlier (with rewrite commented) I saw at least the "Hello of World" page of the main domain.

This is /var/www/system/MyDomain/conf/nginx_ip_default.conf
Code:
#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

server {
   listen My-IP-Address:443 default_server ssl http2;

   server_name MyDomain;
   server_name www.MyDomain;
   server_name ipv4.MyDomain;

   ssl_certificate             /usr/local/psa/var/certificates/cert-jevJ0y;
   ssl_certificate_key         /usr/local/psa/var/certificates/cert-jevJ0y;
   ssl_client_certificate      /usr/local/psa/var/certificates/cert-LhchZz;

   client_max_body_size 128m;

   root "/var/www/vhosts/MyAccount/httpdocs/MyDomain";
   access_log "/var/www/vhosts/system/MyDomain/logs/proxy_access_ssl_log";
   error_log "/var/www/vhosts/system/MyDomain/logs/proxy_error_log";

   location ^~ /plesk-site-preview/ {
       proxy_pass http://127.0.0.1:8880;
       proxy_set_header Host             plesk-site-preview.local;
       proxy_set_header X-Real-IP        $remote_addr;
       proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
       proxy_cookie_domain plesk-site-preview.local $host;
       access_log off;
   }

   if ($host ~* ^www\.domain\.eu$) {
       rewrite ^(.*)$ https://MyDomain$1 permanent;
   }

   #extension wp-toolkit begin
   location ~* wp-config.php { deny all; }

   #extension wp-toolkit end

   location / {
       proxy_pass https://My-IP-Address:7081;
       proxy_set_header Host             $host;
       proxy_set_header X-Real-IP        $remote_addr;
       proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
       proxy_set_header X-Accel-Internal /internal-nginx-static-location;
       access_log off;
   }

   location /internal-nginx-static-location/ {
       alias /var/www/vhosts/MyAccount/httpdocs/MyDomain/;
       internal;
   }

   location ~ ^/(plesk-stat|awstats-icon|webstat|webstat-ssl|ftpstat|anon_ftpstat) {
       proxy_pass https://My-IP-Address:7081;
       proxy_set_header Host             $host;
       proxy_set_header X-Real-IP        $remote_addr;
       proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
       proxy_set_header X-Accel-Internal /internal-nginx-static-location;
       access_log off;
   }

   location ~ ^/files/ {
       proxy_pass https://My-IP-Address:7081;
       proxy_set_header Host             $host;
       proxy_set_header X-Real-IP        $remote_addr;
       proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
       proxy_set_header X-Accel-Internal /internal-nginx-static-location;
       access_log off;
   }

   location ~ ^/~(.+?)(/.*?\.php)(/.*)?$ {
       alias /var/www/vhosts/MyAccount/web_users/$1/$2;
       fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
       fastcgi_param PATH_INFO $fastcgi_path_info;
       fastcgi_pass "unix:///var/www/vhosts/system/MyDomain/php-fpm.sock";
       include /etc/nginx/fastcgi.conf;
   }

   location ~ ^/~(.+?)(/.*)?$ {
       proxy_pass https://My-IP-Address:7081;
       proxy_set_header Host             $host;
       proxy_set_header X-Real-IP        $remote_addr;
       proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
       proxy_set_header X-Accel-Internal /internal-nginx-static-location;
       access_log off;
   }

   location ~ \.php(/.*)?$ {
       fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
       fastcgi_param PATH_INFO $fastcgi_path_info;
       fastcgi_pass "unix:///var/www/vhosts/system/MyDomain/php-fpm.sock";
       include /etc/nginx/fastcgi.conf;
   }

   location ~ /$ {
       index "index.html" "index.cgi" "index.pl" "index.php" "index.xhtml" "index.htm" "index.shtml";
   }

   add_header X-Powered-By PleskLin;

   include "/var/www/vhosts/system/MyDomain/conf/vhost_nginx.conf";
}

server {
   listen My-IP-Address:80 default_server;

   server_name MyDomain;
   server_name www.MyDomain;
   server_name ipv4.MyDomain;

   client_max_body_size 128m;

   return 301 https://$host$request_uri;
 
This is /var/www/system/MyDomain/conf/nginx.conf (empty!)
Code:
#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

This is /var/www/system/_.MyDomain/conf/nginx.conf
Code:
#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

server {
   listen My-IP-Address:443 ssl http2;

   server_name _.MyDomain;
   server_name ~^.*\.domain\.eu$;

   ssl_certificate             /usr/local/psa/var/certificates/certA6wbmJt;
   ssl_certificate_key         /usr/local/psa/var/certificates/certA6wbmJt;

   client_max_body_size 128m;

   root "/var/www/vhosts/MyAccount/httpdocs/MyDomain";
   access_log "/var/www/vhosts/system/_.MyDomain/logs/proxy_access_ssl_log";
   error_log "/var/www/vhosts/system/_.MyDomain/logs/proxy_error_log";

   #extension wp-toolkit begin
   location ~* wp-config.php { deny all; }

   #extension wp-toolkit end

   location / {
       proxy_pass https://My-IP-Address:7081;
       proxy_set_header Host             $host;
       proxy_set_header X-Real-IP        $remote_addr;
       proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
       proxy_set_header X-Accel-Internal /internal-nginx-static-location;
       access_log off;
   }

   location /internal-nginx-static-location/ {
       alias /var/www/vhosts/MyAccount/httpdocs/MyDomain/;
       internal;
   }

   location ~ ^/(plesk-stat|awstats-icon|webstat|webstat-ssl|ftpstat|anon_ftpstat) {
       proxy_pass https://My-IP-Address:7081;
       proxy_set_header Host             $host;
       proxy_set_header X-Real-IP        $remote_addr;
       proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
       proxy_set_header X-Accel-Internal /internal-nginx-static-location;
       access_log off;
   }

   add_header X-Powered-By PleskLin;

}

server {
   listen My-IP-Address:80;

   server_name _.MyDomain;
   server_name ~^.*\.domain\.eu$;

   client_max_body_size 128m;

   root "/var/www/vhosts/MyAccount/httpdocs/MyDomain";
   access_log "/var/www/vhosts/system/_.MyDomain/logs/proxy_access_log";
   error_log "/var/www/vhosts/system/_.MyDomain/logs/proxy_error_log";

   #extension wp-toolkit begin
   location ~* wp-config.php { deny all; }

   #extension wp-toolkit end

   location / {
       proxy_pass http://My-IP-Address:7080;
       proxy_set_header Host             $host;
       proxy_set_header X-Real-IP        $remote_addr;
       proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
       proxy_set_header X-Accel-Internal /internal-nginx-static-location;
       access_log off;
   }

   location /internal-nginx-static-location/ {
       alias /var/www/vhosts/MyAccount/httpdocs/MyDomain/;
       internal;
   }

   location ~ ^/(plesk-stat|awstats-icon|webstat|webstat-ssl|ftpstat|anon_ftpstat) {
       proxy_pass http://My-IP-Address:7080;
       proxy_set_header Host             $host;
       proxy_set_header X-Real-IP        $remote_addr;
       proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
       proxy_set_header X-Accel-Internal /internal-nginx-static-location;
       access_log off;
   }

   add_header X-Powered-By PleskLin;

}
 
Last edited:
Hi WhiteTiger,

Can this change the suggested configurations?
No, it doesn't.

but in Plesk there are many domains and some are associated with Joomla or Prestashop.So, tThese changes will also modify domains without WP.
And there is absolutely nothing wrong with that, as GZIP - compression can be done with ALL content. ;)

WhiteTiger said:
Code:
#user  nginx;
worker_processes  1;
Consider to adjust the "worker_processes" to your actual amount of CPU cores.

WhiteTiger said:
Code:
#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;
If you miss to define any log, you will never be able to investigate ( possible ) issues/errors/porblems, which are not domain - specific - related.

With this code I see the Home Page of main domain ad second domain, but now I can no longer see the "Hello world" page of both domains.
Earlier (with rewrite commented) I saw at least the "Hello of World" page of the main domain.
I'm afraid, that I can only tell you for this issue/error/problem, that you have to check your ".htaccess" - files and the corresponding nginx directives in such a case. It helps a lot, when you investigate such issues with the help of your (sub)domain - specific - log - files, as they mostly point directly to your issues/errors/problems and you are then able to correct it.



( For your ( possible ) next upload of a set of configuration files as attachments, consider to zip them together in a folder. ;) )
 
...
No, it doesn't.
And there is absolutely nothing wrong with that, as GZIP - compression can be done with ALL content. ;)
Your suggestion was about blogid and include about a WP Plugin (Nginx_helper).


If you miss to define any log, you will never be able to investigate ( possible ) issues/errors/porblems, which are not domain - specific - related.
In /var/log/nginx I already see error.log.
 
Hi WhiteTiger,

Your suggestion was about blogid and include about a WP Plugin (Nginx_helper).
Correct, I suggested this as well. But I hope that you are aware, that there is no http - section in your existing (sub)domain - specific configuration files, which leaves you with two possible options:
  • Either follow my previous suggestion
  • Create a separate file at for example => /etc/nginx/plesk.conf.d/ip_default/my_YOUR-DOMAIN.COM_map_configuration.conf
 
I prefer the second solution since it would be used specifically for WP.

I see there is a configuration file for domain aliases.
Since all domains are mapped to the multisite WP through this alias, may it be possible that this configuration file to affect the behavior of the main WP?
In other words, we are focusing attention on the main domain configuration files and instead the alias file is considered.

Finally, /var/www/system/MyDomain/conf/nginx.conf is empty.
What parameters of the Panel change it?

There is an option in Domain Panel to disable Nginx and to work only with Apache?

But let me add a personal opinion, absolutely without controversy.

There are no customer domains on this server at this time, but if there were one, they would not be able to modify system configuration files or php templates.
So how can I set up configurations if they can only use the Nginx Settings in the domain panel?
There will also be a way, for example, with a Include invoked before standard options are defined.
 
Last edited:
Hi WhiteTiger,

Finally, /var/www/system/MyDomain/conf/nginx.conf is empty.
What parameters of the Panel change it?
Pls. have a closer look at the Plesk documentation:


Depending to your domain - specific webserver settings, the configuration files vary with it's content and pls. note, that IF you setup a "main" - domain for your IP(s), you have to note, that "nginx.conf" will be replaced by "nginx_ip_default.conf" and "httpd.conf" will be replaced by "httpd_ip_default.conf".


they would not be able to modify system configuration files or php templates.
Correct. Then they certainly shouldn't be able do that at all, as it would affect other domains/customers on your server! ;)

So how can I set up configurations if they can only use the Nginx Settings in the domain panel?
That's why you and your customer(s) have the possibility to add "Additional HTTP/HTTPS directives" and "Additional NGINX directives" over your domain specific webserver settings.
The "map" - configuration for nginx for example is a very rare situation, where the server administrator has to interfere manually for his customer(s) and this exeption is a really rare case. ;)
 
Thanks, but you did not answer my most important question: how can I disable Nginx for single domain?
If I have to do tests with htaccess I need to work only with Apache and this only at the affected domain level without disturbing the other domains.

There is no trace of this in the documentation that, I repeat, I have already read it all.
Unless I'm wrong.
 
Hi WhiteTiger,

pls. consider to use as well CLI - commands, to inform yourself about the possible options, when you use Plesk:

Code:
plesk bin subscription --help

Hint: NGINX - related command options:
Code:
-nginx-proxy-mode

-nginx-transparent-mode

-nginx-serve-static

-nginx-static-extensions

-nginx-serve-php
You might find it helpfull, to read as well the corresponding online documentation:
 
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:
  1. 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.
  2. I've also read dozens of Internet pages about Nginx, WP and WP on Nginx.
  3. I've also read dozens of threads on this forum, the WP forum and others like "Stackoverflow".
  4. 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):
  1. I have only one static IP and so I have created only one Unlimited subscription.
  2. 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, ...
  3. 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:
  1. How can I maintain a granularity of configurations for each domain so that it is possible to use specific directives for each server application?
  2. How can I disable Nginx at a single domain level working with Apache, while for all other domains continue to use the Reverse Proxy?
  3. Obviously, how should htaccess directives be converted and where should they go?
  4. 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.
 
Last edited:
I renew the request.
This "htaccess" code works by deactivating Nginx.
Instead with Nginx active, how and where can I place it at a single domain level without disturbing the configurations of other domains?
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]

Thanks in advance.
 
Back
Top