zoukankan      html  css  js  c++  java
  • 隐藏或修改nginx返回的Server信息(以及隐藏版本号)

    如何隐藏nginx版本号:

    [root@localhost /]# vi /etc/nginx/nginx.conf
    [root@localhost /]# nginx -t
    [root@localhost /]# nginx -s reload

    配置文件中,http区段中插入“server_tokens  off;”,重新载入配置文件

    worker_processes  1;
    events {
        worker_connections  1024;
    }
    http {
        include       mime.types;
        default_type  application/octet-stream;
        server_tokens  off;
        expires         5s;
        sendfile        on;

    隐藏或修改nginx返回的Server信息:

    [root@localhost /]# vi /opt/nginx/nginx-1.2.0/src/http/ngx_http_special_response.c 
    找到29行:修改展示名称(LLSERVER)
    [root@localhost /]# "<hr><center>LLSERVER</center>" CRLF
    [root@localhost /]# cd
    /opt/nginx/nginx-1.2.0/src/http/ngx_http_header_filter_module.c
    [root@localhost /]# vi
    /opt/nginx/nginx-1.2.0/src/http/ngx_http_header_filter_module.c
    找到49和50行: 修改展示名称(Server: LLSERVER)
    [root@localhost /]# static char ngx_http_server_string[] = "Server: LLSERVER" CRLF;
    [root@localhost /]# static char ngx_http_server_full_string[] = "Server: LLSERVER " NGINX_VER CRLF;
    隐藏nginx请求头header:修改nginx.conf ,在location中添加配置如下:
    [root@localhost /]# proxy_hide_header X-Frame-Options;   //将X-Frame-Options换成Location
    [root@localhost /]# add_header X-Frame-Options SAMEORIGIN always; //将X-Frame-Options换成Location
  • 相关阅读:
    Solr的配置和在java中的使用
    druid + mysql + mybatis 批量更新报错
    linux find命令-print0和xargs中-0使用技巧
    Shell 函数相关
    公钥、私钥和数字签名这样最好理解
    Liunx find/locate/whereis/which 总结
    Linux find命令
    Shell bash 数学运算 bc
    Shell 使用 expr 进行数学运算
    Shell 有类型变量
  • 原文地址:https://www.cnblogs.com/LJing21/p/14769435.html
Copyright © 2011-2022 走看看