欢迎光临
我们一直在努力

nginx 自定义 Server Name 隐藏软件名 自定义版本

How To Customize Your Nginx Server Name

  • src/core/nginx.h
    #define NGINX_VER "MYWS/“ NGINX_VERSION
  • http/ngx_http_special_response.c
    "<hr><center>MYWS</center>” CRLF
  • http/ngx_http_header_filter_module.c
    static u_char ngx_http_server_string[] = "Server: MYWS" CRLF;
  • src/http/v2/ngx_http_v2_filter_module.c
    static const u_char nginx[5] = "\x84\xd1\xcf\x96\xef";

第4点是为http2 做的修改.字节码生成:

package main

import (
    "fmt"
    "golang.org/x/net/http2/hpack"
)

func main() {
    fmt.Println("nginx", "→", Encode("ithothub"))
    fmt.Println("nginx", "→", Encode("nginx"))
    fmt.Println("apache", "→", Encode("apache"))
}

func Encode(s string) string {
    var result string

    hd := hpack.AppendHuffmanString(nil, s)
    hl := hpack.HuffmanEncodeLength(s) | 0x80

    result += RenderByte(byte(hl))

    for _, b := range hd {
        result += RenderByte(b)
    }

    return result
}

func Decode(s string) string {
    data := []byte(s)
    result, _ := hpack.HuffmanDecodeToString(data[1:])
    return result
}

func RenderByte(b byte) string {
    return fmt.Sprintf("\\x%x", b)
}

 

 

赞(7) 打赏
转载请注明来源:IT技术资讯 » nginx 自定义 Server Name 隐藏软件名 自定义版本

评论 抢沙发

评论前必须登录!

 

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏