nginx中隐藏响应头/返回头信息/php版本号/服务器信息

作者:袖梨 2022-06-30

首先隐藏nginx版本信息,只需编辑 nginx.conf 文件
添加一行

代码如下 复制代码

server_tokens off;

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
index index.php index.html index.htm;
server_tokens off;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}

响应头隐藏PHP版本休息,编辑php.ini文件找到expose_php = On , 修改为 expose_php = Off

代码如下 复制代码

;;;;;;;;;;;;;;;;;
; Miscellaneous ;
;;;;;;;;;;;;;;;;;

; Decides whether PHP may expose the fact that it is installed on the server
; (e.g. by adding its signature to the Web server header). It is no security
; threat in any way, but it makes it possible to determine whether you use PHP
; on your server or not.
; http://www.***php.net/manual/en/ini.core.php#ini.expose-php
expose_php = Off

相关文章

精彩推荐