This commit is contained in:
root 2026-08-14 17:11:55 +08:00
parent e64960e521
commit 1ce8efb39e
2 changed files with 60 additions and 1 deletions

View File

@ -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;"]

56
no-server-header.patch Normal file
View File

@ -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,