• 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
  • Inviting everyone to the UX test of a new security feature in the WP Toolkit
    For WordPress site owners, threats posed by hackers are ever-present. Because of this, we are developing a new security feature for the WP Toolkit. If the topic of WordPress website security is relevant to you, we would be grateful if you could share your experience and help us test the usability of this feature. We invite you to join us for a 1-hour online session via Google Meet. Select a convenient meeting time with our friendly UX staff here.

Resolved Enable a PHP socket for nginx for custom website outside Plesk

mr-wolf

Silver Pleskian
Plesk Guru
I have created an autodiscovery for mail that uses 5 Plesk servers.
For this I use nginx and a PHP-socket.

In /etc/nginx/conf.d I have this file:

/etc/nginx/conf.d/zz005_autodiscover.conf
Code:
server {
    listen *:80;
    server_name ~^autoconfig\.[a-z0-9-]+\.[a-z0-9-]+$;

    root  /var/www/autoconfig_autodiscover;

    index index.html;
    error_log /var/log/nginx/autoconfig_autodiscover/error.log;
    access_log /var/log/nginx/autoconfig_autodiscover/access.log combined;

    location /mail/config-v1.1.xml {
      try_files $uri /config-v1.1.xml.php?$args;
      rewrite ^(.+)$ /config-v1.1.xml.php?$1 last;
    }


   location ~ config-v1\.1\.xml\.php$ {
     try_files $uri =404;
     include /etc/nginx/fastcgi_params;
     fastcgi_pass 127.0.0.1:9000;
     fastcgi_index index.php;
     fastcgi_param SERVER_FQDN  $host;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     fastcgi_param PATH_INFO $fastcgi_script_name;
     fastcgi_intercept_errors on;
   }
}


server {
    listen *:443 ssl;
    server_name ~^[a-z0-9-]+-[a-z0-9-]+\.provider.com$;
    root  /var/www/autoconfig_autodiscover;

    error_log /var/log/nginx/autoconfig_autodiscover/error.log;
    access_log /var/log/nginx/autoconfig_autodiscover/access.log combined;

    ssl_certificate             /root/.ssh/wildcard.provider.com.pem;
    ssl_certificate_key         /root/.ssh/wildcard.provider.com.key;

    ssl_stapling on;
    ssl_stapling_verify on;

    ssl_session_timeout         5m;

    # ssl_protocols               SSLv2 SSLv3 TLSv1;
    ssl_protocols               TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers                 HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;
    ssl_dhparam /etc/ssl/certs/dhparam.pem;

    client_max_body_size 1m;

    index index.php index.html index.htm;

    location /autodiscover/autodiscover.xml {
      try_files $uri /autodiscover.xml.php?$args;
      rewrite ^(.+)$ /autodiscover.xml.php?$1 last;
    }

   location ~ autodiscover\.xml\.php$ {
     try_files $uri =404;
     include /etc/nginx/fastcgi_params;
     fastcgi_pass 127.0.0.1:9000;
     fastcgi_index index.php;
     fastcgi_param SERVER_FQDN  $host;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     fastcgi_param PATH_INFO $fastcgi_script_name;
     fastcgi_intercept_errors on;
    }
}

By examining the server with netstat I saw that on 1 server it was running on tcp port 9000
On that server I could use
Code:
fastcgi_pass 127.0.0.1:9000;
on 3 other servers it was a unix socket and there I use
Code:
fastcgi_pass unix:/run/php/php7.0-fpm.sock

On the 5th server I have a problem.
There is no socket already running.
I read this page: https://support.rackspace.com/how-to/install-nginx-and-php-fpm-running-on-unix-file-sockets/

But when I go to /etc/php5/fpm/pool.d I can see that Plesk deliberately turned off by making a new www.conf and renaming the original one to www.conf.saved_by_psa

I don't have that much experience with how this is used and I'm a bit afraid to break something.

The whole autoconfiguration / autodiscovery system is working now and it would be a shame if this server stops me from implementing it.
 
Hi mr-wolf,

But when I go to /etc/php5/fpm/pool.d I can see that Plesk deliberately turned off by making a new www.conf and renaming the original one to www.conf.saved_by_psa
Pls. feel free to add unique PHP - configuration files, as the one called "www.conf" ( provided as standart from the PHP - vendor ). Plesk just renames this file to limit resource usage on your server for possible service - instances, that you might not need.
On our servers, we use unique FPM - configuration files for EACH PHP version on the servers, named as "www_modified-by-admin.conf", to prevent Plesk from renaming them. ;)
 
Hi mr-wolf,


Pls. feel free to add unique PHP - configuration files, as the one called "www.conf" ( provided as standart from the PHP - vendor ). Plesk just renames this file to limit resource usage on your server for possible service - instances, that you might not need.
On our servers, we use unique FPM - configuration files for EACH PHP version on the servers, named as "www_modified-by-admin.conf", to prevent Plesk from renaming them. ;)

Thank you very much...
That worked.

It is working on 127.0.0.1:9000
It turned out that one of the 4 also had the same problem.
The original config was using a unix socket and that didn't work (/var/run/php5-fpm.sock)
I switched it to an IP / port
 
Back
Top