• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • Our UX team believes in the in the power of direct feedback and would like to invite you to participate in interviews, tests, and surveys.
    To stay in the loop and never miss an opportunity to share your thoughts, please subscribe to our UX research program. If you were previously part of the Plesk UX research program, please re-subscribe to continue receiving our invitations.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

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