1. 程式人生 > >隱藏Nginx和PHP版本號

隱藏Nginx和PHP版本號

Nginx php

OS:CentOS release 6.9 (Final)

任務:隱藏Nginx、PHP版本號

[root@sky9890 html]# curl -I 101.132.79.69/

HTTP/1.1 200 OK

Server: nginx/1.10.3

Date: Mon, 16 Apr 2018 03:26:32 GMT

Content-Type: text/html

Connection: keep-alive

X-Powered-By: PHP/5.3.27

隱藏Nginx版本號:

nginx配置文件nginx.conf,http{...}中加入以下代碼

http {

server_tokens off;

}

[root@sky9890 conf]# curl -I 101.132.79.69

HTTP/1.1 200 OK

Server: nginx #隱藏了版本號

Date: Mon, 16 Apr 2018 03:31:17 GMT

Content-Type: text/html

Connection: keep-alive

X-Powered-By: PHP/5.3.27

php中隱藏版本號的方法:

php配置文件php.ini,修改如下:

[root@sky9890 lib]# vi /usr/local/php/lib/php.ini

expose_php = On #expose_php = Off

[root@sky9890 /]# killall php-fpm

[root@sky9890 /]# /usr/local/php/sbin/php-fpm #重新啟動此服務


[root@sky9890 conf]# curl -I 101.132.79.69

HTTP/1.1 200 OK

Server: nginx

Date: Mon, 16 Apr 2018 03:31:17 GMT

Content-Type: text/html

Connection: keep-alive

#沒有顯示php版本信息了


隱藏Nginx和PHP版本號