Взгляните на InSpec, инструмент, который позволяет вам «превратить соответствие требованиям, требованиям безопасности и другим политикам в автоматизированные тесты».
https://www.inspec.io
Он может выполнить все тесты конфигурации, которые вам нужны для вашего сервера Nginx. Вот один из способов проверить наличие файла conf и значение server_tokens:
conf_path = '/etc/nginx/nginx.conf'
control 'Server tokens should be off' do
describe file(conf_path) do
it 'The config file should exist and be a file.' do
expect(subject).to(exist)
expect(subject).to(be_file)
end
end
if (File.exist?(conf_path))
Array(nginx_conf(conf_path).params['http']).each do |http|
describe "http:" do
it 'server_tokens should be off if found in the http context.' do
Array(http["server_tokens"]).each do |tokens|
expect(tokens).to(cmp 'off')
end
end
end
end
end
end
Если установлено правильно, InSpec возвращает:
✔ Server tokens should be off: File /etc/nginx/nginx.conf
✔ File /etc/nginx/nginx.conf The config file should exist and be a file.
✔ http: server_tokens should be off if found in the http context.
Если не:
× Server tokens should be off: File /etc/nginx/nginx.conf (1 failed)
✔ File /etc/nginx/nginx.conf The config file should exist and be a file.
× http: server_tokens should be off if found in the http context.
expected: "off"
got: ["on"]
(compared using `cmp` matcher)
server_tokenне имеет ничего общего с версией PHP. Обычно отправляется в отдельном заголовкеX-Powered-By. Полагаю, вам нужен php.net/manual/en/ini.core.php#ini.expose-php