zl程序教程

您现在的位置是:首页 >  后端

当前栏目

modify nginx Server header

serverNginx header modify
2023-09-11 14:16:16 时间

  

 

 

 

  1. server_tokens off;

     

     

  2. add_header

     

     

  3. proxy_pass_header 可把后端Server透传到browser, 适用于代理

     

     

  4. server_tokens build;

     

     Building nginx from Sources  nginx编译选项



  5. src/core/nginx.h

     

     

     

     

     定义三个宏

    NGINX_VERSION
    NGINX_VER
    NGINX_VER_BUILD

    编译参数加入 --build=build_name


     

     

     

     

     

     

  6. server_tokens off; 此时需要修改源码 src/http/ngx_http_header_filter_module.c 如下位置

     

     需改如下, 亦可使用宏

     

     

     

     

  7.  

    使用第三方模块
    https://github.com/openresty/headers-more-nginx-module/archive/master.zip

    加入编译参数
    --add-dynamic-module=/usr/local/headers-more-nginx-module-0.33

    加载模块
    load_module modules/ngx_http_headers_more_filter_module.so;

    加入指令
    more_set_headers 'Server: -';     优先级最高