1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# diff -Nau nginx-1.30.0/src/http/v2/ngx_http_v2_filter_module.c nginx-1.30.0_patched/src/http/v2/ngx_http_v2_filter_module.c > nginx-without-server-header/ngx_http_v2_filter_module.c.patch
--- nginx-1.30.0/src/http/v2/ngx_http_v2_filter_module.c 2026-04-14 10:10:11.000000000 -0300
+++ nginx-1.30.0_patched/src/http/v2/ngx_http_v2_filter_module.c 2026-04-16 20:42:19.710788321 -0300
@@ -120,20 +120,13 @@
ngx_http_core_srv_conf_t *cscf;
u_char addr[NGX_SOCKADDR_STRLEN];
- static const u_char nginx[5] = { 0x84, 0xaa, 0x63, 0x55, 0xe7 };
+ static const u_char nginx[3] = { 0x82, 0xf0, 0x8f };
#if (NGX_HTTP_GZIP)
static const u_char accept_encoding[12] = {
0x8b, 0x84, 0x84, 0x2d, 0x69, 0x5b, 0x05, 0x44, 0x3c, 0x86, 0xaa, 0x6f
};
#endif
- static size_t nginx_ver_len = ngx_http_v2_literal_size(NGINX_VER);
- static u_char nginx_ver[ngx_http_v2_literal_size(NGINX_VER)];
-
- static size_t nginx_ver_build_len =
- ngx_http_v2_literal_size(NGINX_VER_BUILD);
- static u_char nginx_ver_build[ngx_http_v2_literal_size(NGINX_VER_BUILD)];
-
stream = r->stream;
if (!stream) {
@@ -223,17 +216,9 @@
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
- if (r->headers_out.server == NULL) {
-
- if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) {
- len += 1 + nginx_ver_len;
-
- } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) {
- len += 1 + nginx_ver_build_len;
-
- } else {
- len += 1 + sizeof(nginx);
- }
+ if ( (r->headers_out.server == NULL) &&
+ (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) ) {
+ len += 1 + sizeof(nginx);
}
if (r->headers_out.date == NULL) {
@@ -427,47 +412,14 @@
pos = ngx_sprintf(pos, "%03ui", r->headers_out.status);
}
- if (r->headers_out.server == NULL) {
-
- if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) {
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, fc->log, 0,
- "http2 output header: \"server: %s\"",
- NGINX_VER);
-
- } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) {
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, fc->log, 0,
- "http2 output header: \"server: %s\"",
- NGINX_VER_BUILD);
-
- } else {
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0,
- "http2 output header: \"server: nginx\"");
- }
+ if ( (r->headers_out.server == NULL) &&
+ (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) ) {
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, fc->log, 0,
+ "http2 output header: \"server: ws\"");
*pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_SERVER_INDEX);
- if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) {
- if (nginx_ver[0] == '\0') {
- p = ngx_http_v2_write_value(nginx_ver, (u_char *) NGINX_VER,
- sizeof(NGINX_VER) - 1, tmp);
- nginx_ver_len = p - nginx_ver;
- }
-
- pos = ngx_cpymem(pos, nginx_ver, nginx_ver_len);
-
- } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) {
- if (nginx_ver_build[0] == '\0') {
- p = ngx_http_v2_write_value(nginx_ver_build,
- (u_char *) NGINX_VER_BUILD,
- sizeof(NGINX_VER_BUILD) - 1, tmp);
- nginx_ver_build_len = p - nginx_ver_build;
- }
-
- pos = ngx_cpymem(pos, nginx_ver_build, nginx_ver_build_len);
-
- } else {
- pos = ngx_cpymem(pos, nginx, sizeof(nginx));
- }
+ pos = ngx_cpymem(pos, nginx, sizeof(nginx));
}
if (r->headers_out.date == NULL) {
|