文章插图
安全优化-隐藏版本号server_tokensSyntax: server_tokens on | off | build | string;
Default: server_tokens on;
Context: http, server, location
在主配置文件Nginx.conf、虚拟主机的配置文件中配置,选一个配置即可
官方文档地址:http://nginx.org/en/docs/http/ngx_http_core_module.html#server_tokens
在主配置文件nginx.conf加入
[root@web01 conf]# cat /Application/nginx/conf/nginx.confworker_processes2;error_log logs/error.log; #配置Nginx worker进程最大打开文件数worker_rlimit_nofile 65535; user www www;events {#单个进程允许的客户端最大连接数worker_connections20480;}http {includemime.types;default_typeapplication/octet-stream;sendfileon;keepalive_timeout65;#访问日志配置log_formatmain'$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';#虚拟主机include /application/nginx/conf/extra/www.conf;include /application/nginx/conf/extra/blog.conf;include /application/nginx/conf/extra/bbs.conf;include /application/nginx/conf/extra/edu.conf;include /application/nginx/conf/extra/phpmyadmin.conf;include /application/nginx/conf/extra/status.conf;#隐藏版本号server_tokens off;}
在虚拟主机的配置文件中添加
[root@web01 conf]# cat /application/nginx/conf/extra/www.conf server {listen80;server_name www.abc.com;rewrite ^(.*)$https://$host$1 permanent;}server {listen443;server_namewww.abc.com;#https证书ssl on;ssl_certificate /application/nginx/conf/key/server.crt;ssl_certificate_key /application/nginx/conf/key/server.key;#访问日志access_loglogs/access_www.logmain buffer=32k flush=5s;location / {roothtml/www;indexindex.php index.html index.htm;}#隐藏版本号server_tokens off;#php解析location ~ .*.(php|php5)?$ {root html/www;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fastcgi.conf;}}
【nginx 简单隐藏服务器版本号】
推荐阅读
- 花茶VS花草茶,什么是花草茶
- MacBook 性能提升方法
- 五分钟看穿Java并发相关概念,并发原来如此简单
- 喝洛神花茶的好处,喝菊花茶的好处
- 花茶怎样挑选,花茶如何品饮
- 玫瑰花茶降火吗,玫瑰花茶怎么泡
- 孕妇能喝合欢花茶吗,孕妇能喝菊花茶吗
- 如何选购花茶,茉莉花茶如何喝
- 喝藏红花茶适宜人群,芍药花茶
- 玫瑰花茶种植条件,玫瑰花茶怎么泡