summarylogtreecommitdiffstats
path: root/ngx_http_header_filter_module.c.patch
blob: f92b159a2e629b40a62ef56602bc177bdd01ffc5 (plain)
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
# diff -Nau nginx-1.30.0/src/http/ngx_http_header_filter_module.c nginx-1.30.0_patched/src/http/ngx_http_header_filter_module.c > nginx-without-server-header/ngx_http_header_filter_module.c.patch
--- nginx-1.30.0/src/http/ngx_http_header_filter_module.c	2026-04-14 10:10:11.000000000 -0300
+++ nginx-1.30.0_patched/src/http/ngx_http_header_filter_module.c	2026-04-16 20:17:45.472364011 -0300
@@ -47,9 +47,7 @@
 };
 
 
-static u_char ngx_http_server_string[] = "Server: nginx" CRLF;
-static u_char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;
-static u_char ngx_http_server_build_string[] = "Server: " NGINX_VER_BUILD CRLF;
+static u_char ngx_http_server_string[] = "Server: ws" CRLF;
 
 static ngx_str_t ngx_http_early_hints_status_line =
     ngx_string("HTTP/1.1 103 Early Hints" CRLF);
@@ -287,17 +285,10 @@
 
     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 += sizeof(ngx_http_server_full_string) - 1;
-
-        } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) {
-            len += sizeof(ngx_http_server_build_string) - 1;
-
-        } else {
-            len += sizeof(ngx_http_server_string) - 1;
-        }
-    }
+    if ( (r->headers_out.server == NULL) &&
+         (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) ) {
+        len += sizeof(ngx_http_server_string) - 1;
+    } 
 
     if (r->headers_out.date == NULL) {
         len += sizeof("Date: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1;
@@ -456,20 +447,11 @@
     }
     *b->last++ = CR; *b->last++ = LF;
 
-    if (r->headers_out.server == NULL) {
-        if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) {
-            p = ngx_http_server_full_string;
-            len = sizeof(ngx_http_server_full_string) - 1;
-
-        } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) {
-            p = ngx_http_server_build_string;
-            len = sizeof(ngx_http_server_build_string) - 1;
-
-        } else {
-            p = ngx_http_server_string;
-            len = sizeof(ngx_http_server_string) - 1;
-        }
-
+    if ( (r->headers_out.server == NULL) &&
+         (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) ) {
+        p = ngx_http_server_string;
+        len = sizeof(ngx_http_server_string) - 1;
+ 
         b->last = ngx_cpymem(b->last, p, len);
     }