You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

remove_nginx_server_header.patch 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c
  2. index 9b894059..1a07dace 100644
  3. --- a/src/http/ngx_http_header_filter_module.c
  4. +++ b/src/http/ngx_http_header_filter_module.c
  5. @@ -46,11 +46,6 @@ ngx_module_t ngx_http_header_filter_module = {
  6. };
  7. -static u_char ngx_http_server_string[] = "Server: nginx" CRLF;
  8. -static u_char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;
  9. -static u_char ngx_http_server_build_string[] = "Server: " NGINX_VER_BUILD CRLF;
  10. -
  11. -
  12. static ngx_str_t ngx_http_status_lines[] = {
  13. ngx_string("200 OK"),
  14. @@ -279,18 +274,6 @@ ngx_http_header_filter(ngx_http_request_t *r)
  15. clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
  16. - if (r->headers_out.server == NULL) {
  17. - if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) {
  18. - len += sizeof(ngx_http_server_full_string) - 1;
  19. -
  20. - } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) {
  21. - len += sizeof(ngx_http_server_build_string) - 1;
  22. -
  23. - } else {
  24. - len += sizeof(ngx_http_server_string) - 1;
  25. - }
  26. - }
  27. -
  28. if (r->headers_out.date == NULL) {
  29. len += sizeof("Date: Mon, 28 Sep 1970 06:00:00 GMT" CRLF) - 1;
  30. }
  31. @@ -448,23 +431,6 @@ ngx_http_header_filter(ngx_http_request_t *r)
  32. }
  33. *b->last++ = CR; *b->last++ = LF;
  34. - if (r->headers_out.server == NULL) {
  35. - if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) {
  36. - p = ngx_http_server_full_string;
  37. - len = sizeof(ngx_http_server_full_string) - 1;
  38. -
  39. - } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) {
  40. - p = ngx_http_server_build_string;
  41. - len = sizeof(ngx_http_server_build_string) - 1;
  42. -
  43. - } else {
  44. - p = ngx_http_server_string;
  45. - len = sizeof(ngx_http_server_string) - 1;
  46. - }
  47. -
  48. - b->last = ngx_cpymem(b->last, p, len);
  49. - }
  50. -
  51. if (r->headers_out.date == NULL) {
  52. b->last = ngx_cpymem(b->last, "Date: ", sizeof("Date: ") - 1);
  53. b->last = ngx_cpymem(b->last, ngx_cached_http_time.data,
  54. diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
  55. index 2c1ff174..34f3b5c5 100644
  56. --- a/src/http/ngx_http_special_response.c
  57. +++ b/src/http/ngx_http_special_response.c
  58. @@ -19,21 +19,18 @@ static ngx_int_t ngx_http_send_refresh(ngx_http_request_t *r);
  59. static u_char ngx_http_error_full_tail[] =
  60. -"<hr><center>" NGINX_VER "</center>" CRLF
  61. "</body>" CRLF
  62. "</html>" CRLF
  63. ;
  64. static u_char ngx_http_error_build_tail[] =
  65. -"<hr><center>" NGINX_VER_BUILD "</center>" CRLF
  66. "</body>" CRLF
  67. "</html>" CRLF
  68. ;
  69. static u_char ngx_http_error_tail[] =
  70. -"<hr><center>nginx</center>" CRLF
  71. "</body>" CRLF
  72. "</html>" CRLF
  73. ;
  74. diff --git a/src/http/v2/ngx_http_v2_filter_module.c b/src/http/v2/ngx_http_v2_filter_module.c
  75. index 853faefd..71480853 100644
  76. --- a/src/http/v2/ngx_http_v2_filter_module.c
  77. +++ b/src/http/v2/ngx_http_v2_filter_module.c
  78. @@ -148,19 +148,11 @@ ngx_http_v2_header_filter(ngx_http_request_t *r)
  79. ngx_http_core_srv_conf_t *cscf;
  80. u_char addr[NGX_SOCKADDR_STRLEN];
  81. - static const u_char nginx[5] = "\x84\xaa\x63\x55\xe7";
  82. #if (NGX_HTTP_GZIP)
  83. static const u_char accept_encoding[12] =
  84. "\x8b\x84\x84\x2d\x69\x5b\x05\x44\x3c\x86\xaa\x6f";
  85. #endif
  86. - static size_t nginx_ver_len = ngx_http_v2_literal_size(NGINX_VER);
  87. - static u_char nginx_ver[ngx_http_v2_literal_size(NGINX_VER)];
  88. -
  89. - static size_t nginx_ver_build_len =
  90. - ngx_http_v2_literal_size(NGINX_VER_BUILD);
  91. - static u_char nginx_ver_build[ngx_http_v2_literal_size(NGINX_VER_BUILD)];
  92. -
  93. stream = r->stream;
  94. if (!stream) {
  95. @@ -259,19 +251,6 @@ ngx_http_v2_header_filter(ngx_http_request_t *r)
  96. clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
  97. - if (r->headers_out.server == NULL) {
  98. -
  99. - if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) {
  100. - len += 1 + nginx_ver_len;
  101. -
  102. - } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) {
  103. - len += 1 + nginx_ver_build_len;
  104. -
  105. - } else {
  106. - len += 1 + sizeof(nginx);
  107. - }
  108. - }
  109. -
  110. if (r->headers_out.date == NULL) {
  111. len += 1 + ngx_http_v2_literal_size("Wed, 31 Dec 1986 18:00:00 GMT");
  112. }
  113. @@ -480,30 +459,6 @@ ngx_http_v2_header_filter(ngx_http_request_t *r)
  114. "http2 output header: \"server: nginx\"");
  115. }
  116. - *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_SERVER_INDEX);
  117. -
  118. - if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) {
  119. - if (nginx_ver[0] == '\0') {
  120. - p = ngx_http_v2_write_value(nginx_ver, (u_char *) NGINX_VER,
  121. - sizeof(NGINX_VER) - 1, tmp);
  122. - nginx_ver_len = p - nginx_ver;
  123. - }
  124. -
  125. - pos = ngx_cpymem(pos, nginx_ver, nginx_ver_len);
  126. -
  127. - } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) {
  128. - if (nginx_ver_build[0] == '\0') {
  129. - p = ngx_http_v2_write_value(nginx_ver_build,
  130. - (u_char *) NGINX_VER_BUILD,
  131. - sizeof(NGINX_VER_BUILD) - 1, tmp);
  132. - nginx_ver_build_len = p - nginx_ver_build;
  133. - }
  134. -
  135. - pos = ngx_cpymem(pos, nginx_ver_build, nginx_ver_build_len);
  136. -
  137. - } else {
  138. - pos = ngx_cpymem(pos, nginx, sizeof(nginx));
  139. - }
  140. }
  141. if (r->headers_out.date == NULL) {