以前說過如何隱藏Response Headers中 X-Powered-Byphp
修改php.inihtml
expose_php = Off
service php-fpm reload
隱藏Nginx版本號 Servernginx
修改nginx.conf, 在http{}添加web
server_tokens off;
add_header key 'value';
server { listen 80 ; server_name ***.com; index index.html index.htm index.php; root /home/wwwroot/***/backend/web; autoindex on; include enable-php.conf; add_header aaa 'bbb'; access_log /home/wwwlogs/access.log; if (!-e $request_filename){ rewrite ^/(.*) /index.php?r=$1 last; } }
nginx -t
service nginx reload
1: 修改server要在編譯Nginx修改/src/core/nginx.h文件php-fpm
#define NGINX_VERSION "1.14" #define NGINX_VER "nginx"
2: 修改src/http/ngx_http_header_filter_module.cspa
static char ngx_http_server_string[]="Server: nginx" CRLF;
3: 修改src/http/ngx_http_special_response.c3d
static u_char ngx_http_error_tail[]="<hr><center>nginx</center>" CRLF
執行下列代碼查看nginx的配置code
nginx -V
而後configure 加上參數server
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-stream --with-stream_ssl_module
make && make install