去掉 server nginx 响应头
This commit is contained in:
parent
e048df402d
commit
e64960e521
@ -26,7 +26,9 @@ RUN ./config --prefix=/opt/tongsuo-8.4.0 --libdir=lib64 no-shared no-zlib no-thr
|
||||
# ---- Nginx 1.26.2 (linked against Tongsuo) ----
|
||||
WORKDIR /build
|
||||
COPY nginx-1.26.2.tar.gz /build/
|
||||
RUN tar -xzf nginx-1.26.2.tar.gz
|
||||
COPY no-server-header.patch /build/
|
||||
RUN tar -xzf nginx-1.26.2.tar.gz \
|
||||
&& patch -p1 -d nginx-1.26.2 < no-server-header.patch
|
||||
WORKDIR /build/nginx-1.26.2
|
||||
RUN ./configure \
|
||||
--prefix=/usr/local/nginx \
|
||||
|
||||
@ -46,10 +46,6 @@ ngx_module_t ngx_http_header_filter_module = {
|
||||
};
|
||||
|
||||
|
||||
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 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
||||
|
||||
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 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
||||
}
|
||||
*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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user