隐藏404页面中nginx版本信息

278 阅读1分钟

隐藏404页面中nginx版本信息

  • nginx 配置文件 nginx.conf 中加入自定义的 404 页面:
server {
  	server_name localhost;
  	listen 7000; 
  	location / {
  		root /opt/nginx/xdr;
  		index  index.html index.html;
  		# autoindex
  		autoindex on;
  		autoindex_exact_size on;
  		autoindex_localtime on;
        client_max_body_size 100m;
  	}
  	·····
	# 1.配置404页面
    error_page 404 /404.html;
    
    # 2.隐藏Nginx版本信息
    server_tokens off;
  }
  • 上述自定义的 404.html 存放的路径就在 /opt/nginx/xdr
  • 同时还要设置 server_tokens off