regilero / check_phpfpm_status

Nagios check for php-fpm status report
GNU General Public License v3.0
39 stars 19 forks source link

Use servername in SNI request when using SSL #21

Open prupert opened 6 years ago

prupert commented 6 years ago

When using the plugin locally on a specific virtual host with SSL (when using -S explicitly or when the page is behind a redirect to HTTPS) we encounter a HTTP 400 in Apache.

How to reproduce:

./check_phpfpm_status.pl -H localhost -s example.org -u /phpfpm_status -S

Results in HTTP 400 Bad Request because of the following Apache httpd error:

[ssl:error] [pid 12345] AH02032: Hostname localhost provided via SNI and hostname example.org provided via HTTP are different

It appears the -s servername is not used correctly for the SSL request?

We are using CentOS 7's stock Apache (httpd-2.4.6-80.el7.centos.1.x86_64) with TLS 1.2.

regilero commented 6 years ago

Thanks for reporting this. I do not have a lot of time currently, so this issue may be quite slow to be fixed. Do not hesitate to dig around in the code and make a fork/pull request.

prupert commented 6 years ago

My Perl is pretty rusty, but it should work when using the SSL_hostname option in IO::Socket::SSL. It appears you are already doing that, see https://github.com/regilero/check_phpfpm_status/blob/45c0303c4fb7a9e1347d877963e0ec391a8ed089/check_phpfpm_status.pl#L391

Don't know why we are seeing errors then, I'll dig further and let you know.