From 1ce8efb39e0e00bebde4ad6641ab3b4d0b6b2196 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 14 Aug 2026 17:11:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 5 +++- no-server-header.patch | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 no-server-header.patch diff --git a/Dockerfile b/Dockerfile index d7fa3fc..dc6c5ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,6 +60,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ COPY --from=build /usr/local/nginx /usr/local/nginx +# Rename the executable to "gateway" +RUN mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/gateway + # Built-in main nginx config (project root nginx.conf) COPY nginx.conf /usr/local/nginx/conf/nginx.conf @@ -70,4 +73,4 @@ RUN printf '# empty\n' > /usr/local/nginx/conf/man/http/.keep \ EXPOSE 80 443 8443 -CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"] +CMD ["/usr/local/nginx/sbin/gateway", "-g", "daemon off;"] diff --git a/no-server-header.patch b/no-server-header.patch new file mode 100644 index 0000000..4affb04 --- /dev/null +++ b/no-server-header.patch @@ -0,0 +1,56 @@ +--- a/src/http/ngx_http_header_filter_module.c 2026-08-14 11:34:54.186984105 +0800 ++++ b/src/http/ngx_http_header_filter_module.c 2026-08-14 11:34:54.189983714 +0800 +@@ -46,10 +46,6 @@ + }; + + +-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 ngx_str_t ngx_http_status_lines[] = { + +@@ -283,18 +279,6 @@ + + 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.date == NULL) { + len += sizeof("Date: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1; + } +@@ -452,23 +436,6 @@ + } + *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; +- } +- +- b->last = ngx_cpymem(b->last, p, len); +- } +- + if (r->headers_out.date == NULL) { + b->last = ngx_cpymem(b->last, "Date: ", sizeof("Date: ") - 1); + b->last = ngx_cpymem(b->last, ngx_cached_http_time.data,