Skip to content

Instantly share code, notes, and snippets.

@Zenithar
Last active July 7, 2016 20:55
Show Gist options
  • Save Zenithar/70bbb4343d4d9eee4d86 to your computer and use it in GitHub Desktop.
Save Zenithar/70bbb4343d4d9eee4d86 to your computer and use it in GitHub Desktop.
Anonymize NGINX
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 75a4a40..b481fab 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -11,7 +11,7 @@
#define nginx_version 1011002
#define NGINX_VERSION "1.11.2"
-#define NGINX_VER "nginx/" NGINX_VERSION
+#define NGINX_VER "nginx"
#ifdef NGX_BUILD
#define NGINX_VER_BUILD NGINX_VER " (" NGX_BUILD ")"
diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c
index bb9a900..6d0c58c 100644
--- a/src/event/ngx_event_openssl.c
+++ b/src/event/ngx_event_openssl.c
@@ -827,7 +827,7 @@ ngx_ssl_info_callback(const ngx_ssl_conn_t *ssl_conn, int where, int ret)
wbio = SSL_get_wbio((ngx_ssl_conn_t *) ssl_conn);
if (rbio != wbio) {
- (void) BIO_set_write_buffer_size(wbio, NGX_SSL_BUFSIZE);
+ (void) BIO_set_write_buffer_size(wbio, 16384);
c->ssl->handshake_buffer_set = 1;
}
}
diff --git a/src/event/ngx_event_openssl.h b/src/event/ngx_event_openssl.h
index 3367d10..76397f2 100644
--- a/src/event/ngx_event_openssl.h
+++ b/src/event/ngx_event_openssl.h
@@ -135,7 +135,7 @@ typedef struct {
#define NGX_SSL_BUFFER 1
#define NGX_SSL_CLIENT 2
-#define NGX_SSL_BUFSIZE 16384
+#define NGX_SSL_BUFSIZE 1400
ngx_int_t ngx_ssl_init(ngx_log_t *log);
diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c
index f000b2e..e336935 100644
--- a/src/http/ngx_http_header_filter_module.c
+++ b/src/http/ngx_http_header_filter_module.c
@@ -46,8 +46,8 @@ ngx_module_t ngx_http_header_filter_module = {
};
-static char ngx_http_server_string[] = "Server: nginx" CRLF;
-static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;
+static char ngx_http_server_string[] = "";
+static char ngx_http_server_full_string[] = "";
static ngx_str_t ngx_http_status_lines[] = {
@@ -274,8 +274,8 @@ 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) {
- len += clcf->server_tokens ? sizeof(ngx_http_server_full_string) - 1:
- sizeof(ngx_http_server_string) - 1;
+ len += clcf->server_tokens ? sizeof(ngx_http_server_full_string) - 0:
+ sizeof(ngx_http_server_string) - 0;
}
if (r->headers_out.date == NULL) {
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
index 64e5acd..ec36b48 100644
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -19,290 +19,180 @@ static ngx_int_t ngx_http_send_refresh(ngx_http_request_t *r);
static u_char ngx_http_error_full_tail[] =
-"<hr><center>" NGINX_VER "</center>" CRLF
-"</body>" CRLF
-"</html>" CRLF
+"" CRLF
;
static u_char ngx_http_error_tail[] =
-"<hr><center>nginx</center>" CRLF
-"</body>" CRLF
-"</html>" CRLF
+"" CRLF
;
static u_char ngx_http_msie_padding[] =
-"<!-- a padding to disable MSIE and Chrome friendly error page -->" CRLF
-"<!-- a padding to disable MSIE and Chrome friendly error page -->" CRLF
-"<!-- a padding to disable MSIE and Chrome friendly error page -->" CRLF
-"<!-- a padding to disable MSIE and Chrome friendly error page -->" CRLF
-"<!-- a padding to disable MSIE and Chrome friendly error page -->" CRLF
-"<!-- a padding to disable MSIE and Chrome friendly error page -->" CRLF
+"" CRLF
;
static u_char ngx_http_msie_refresh_head[] =
-"<html><head><meta http-equiv=\"Refresh\" content=\"0; URL=";
+"";
static u_char ngx_http_msie_refresh_tail[] =
-"\"></head><body></body></html>" CRLF;
+"" CRLF;
static char ngx_http_error_301_page[] =
-"<html>" CRLF
-"<head><title>301 Moved Permanently</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>301 Moved Permanently</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_302_page[] =
-"<html>" CRLF
-"<head><title>302 Found</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>302 Found</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_303_page[] =
-"<html>" CRLF
-"<head><title>303 See Other</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>303 See Other</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_307_page[] =
-"<html>" CRLF
-"<head><title>307 Temporary Redirect</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>307 Temporary Redirect</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_400_page[] =
-"<html>" CRLF
-"<head><title>400 Bad Request</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>400 Bad Request</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_401_page[] =
-"<html>" CRLF
-"<head><title>401 Authorization Required</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>401 Authorization Required</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_402_page[] =
-"<html>" CRLF
-"<head><title>402 Payment Required</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>402 Payment Required</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_403_page[] =
-"<html>" CRLF
-"<head><title>403 Forbidden</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>403 Forbidden</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_404_page[] =
-"<html>" CRLF
-"<head><title>404 Not Found</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>404 Not Found</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_405_page[] =
-"<html>" CRLF
-"<head><title>405 Not Allowed</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>405 Not Allowed</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_406_page[] =
-"<html>" CRLF
-"<head><title>406 Not Acceptable</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>406 Not Acceptable</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_408_page[] =
-"<html>" CRLF
-"<head><title>408 Request Time-out</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>408 Request Time-out</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_409_page[] =
-"<html>" CRLF
-"<head><title>409 Conflict</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>409 Conflict</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_410_page[] =
-"<html>" CRLF
-"<head><title>410 Gone</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>410 Gone</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_411_page[] =
-"<html>" CRLF
-"<head><title>411 Length Required</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>411 Length Required</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_412_page[] =
-"<html>" CRLF
-"<head><title>412 Precondition Failed</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>412 Precondition Failed</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_413_page[] =
-"<html>" CRLF
-"<head><title>413 Request Entity Too Large</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>413 Request Entity Too Large</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_414_page[] =
-"<html>" CRLF
-"<head><title>414 Request-URI Too Large</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>414 Request-URI Too Large</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_415_page[] =
-"<html>" CRLF
-"<head><title>415 Unsupported Media Type</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>415 Unsupported Media Type</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_416_page[] =
-"<html>" CRLF
-"<head><title>416 Requested Range Not Satisfiable</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>416 Requested Range Not Satisfiable</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_421_page[] =
-"<html>" CRLF
-"<head><title>421 Misdirected Request</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>421 Misdirected Request</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_494_page[] =
-"<html>" CRLF
-"<head><title>400 Request Header Or Cookie Too Large</title></head>"
-CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>400 Bad Request</h1></center>" CRLF
-"<center>Request Header Or Cookie Too Large</center>" CRLF
+"" CRLF
;
static char ngx_http_error_495_page[] =
-"<html>" CRLF
-"<head><title>400 The SSL certificate error</title></head>"
-CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>400 Bad Request</h1></center>" CRLF
-"<center>The SSL certificate error</center>" CRLF
+"" CRLF
;
static char ngx_http_error_496_page[] =
-"<html>" CRLF
-"<head><title>400 No required SSL certificate was sent</title></head>"
-CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>400 Bad Request</h1></center>" CRLF
-"<center>No required SSL certificate was sent</center>" CRLF
+"" CRLF
;
static char ngx_http_error_497_page[] =
-"<html>" CRLF
-"<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>"
-CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>400 Bad Request</h1></center>" CRLF
-"<center>The plain HTTP request was sent to HTTPS port</center>" CRLF
+"" CRLF
;
static char ngx_http_error_500_page[] =
-"<html>" CRLF
-"<head><title>500 Internal Server Error</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>500 Internal Server Error</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_501_page[] =
-"<html>" CRLF
-"<head><title>501 Not Implemented</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>501 Not Implemented</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_502_page[] =
-"<html>" CRLF
-"<head><title>502 Bad Gateway</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>502 Bad Gateway</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_503_page[] =
-"<html>" CRLF
-"<head><title>503 Service Temporarily Unavailable</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>503 Service Temporarily Unavailable</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_504_page[] =
-"<html>" CRLF
-"<head><title>504 Gateway Time-out</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>504 Gateway Time-out</h1></center>" CRLF
+"" CRLF
;
static char ngx_http_error_507_page[] =
-"<html>" CRLF
-"<head><title>507 Insufficient Storage</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
-"<center><h1>507 Insufficient Storage</h1></center>" CRLF
+"" CRLF
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment