Compare commits

..
2 Commits
Author SHA1 Message Date
Hakase 1134c4cd6e Latest update - 7355 2018-09-22 01:04:12 +09:00
Hakase 208765973a Add GeoIP2, Remove GeoIP. 2018-09-22 00:59:05 +09:00
6 changed files with 50 additions and 41 deletions
+5 -2
View File
@@ -4,8 +4,8 @@
Example Web Server - [https://ssl.hakase.io/](https://ssl.hakase.io/) Example Web Server - [https://ssl.hakase.io/](https://ssl.hakase.io/)
## Please install dependency library. ## Please install dependency library.
- CentOS / Red Hat - `yum install jemalloc-devel libuuid-devel libatomic libatomic_ops-devel expat-devel unzip autoconf automake libtool gd-devel geoip-devel gcc-c++ curl` - CentOS / Red Hat - `yum install jemalloc-devel libuuid-devel libatomic libatomic_ops-devel expat-devel unzip autoconf automake libtool gd-devel libmaxminddb-dev gcc-c++ curl`
- Ubuntu / Debian - `apt install libjemalloc-dev uuid-dev libatomic1 libatomic-ops-dev expat unzip autoconf automake libtool libgd-dev libgeoip-dev g++ curl` - Ubuntu / Debian - `apt install libjemalloc-dev uuid-dev libatomic1 libatomic-ops-dev expat unzip autoconf automake libtool libgd-dev libmaxminddb-dev g++ curl`
## How to Install? ## How to Install?
1. Clone this repository - `git clone https://github.com/hakasenyang/nginx-build.git --recursive` 1. Clone this repository - `git clone https://github.com/hakasenyang/nginx-build.git --recursive`
@@ -42,6 +42,8 @@ Example Web Server - [https://ssl.hakase.io/](https://ssl.hakase.io/)
- Strict SNI requires at least two ssl server settings (server { listen 443 ssl }). - Strict SNI requires at least two ssl server settings (server { listen 443 ssl }).
- It does not matter what kind of certificate or duplicate. - It does not matter what kind of certificate or duplicate.
- Use "strict_sni_header on" if you do not want to respond to invalid headers. (only with strict_sni) - Use "strict_sni_header on" if you do not want to respond to invalid headers. (only with strict_sni)
- GeoIP2 Module [#2](https://github.com/hakasenyang/nginx-build/issues/2)
- [Check the following page](https://github.com/leev/ngx_http_geoip2_module) for GeoIP2 settings method.
## Upcoming Features ## Upcoming Features
- Auto build (rpm, deb, etc.) - Auto build (rpm, deb, etc.)
@@ -49,3 +51,4 @@ Example Web Server - [https://ssl.hakase.io/](https://ssl.hakase.io/)
## Deprecated Features ## Deprecated Features
- SPDY (Not compatible this version.) - SPDY (Not compatible this version.)
- GeoIP (Changed to GeoIP2.)
+1 -2
View File
@@ -94,6 +94,7 @@ if [ "$RTMP" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/ngin
if [ "$NAXSI" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/naxsi/naxsi_src"; fi if [ "$NAXSI" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/naxsi/naxsi_src"; fi
if [ "$DAV_EXT" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/nginx-dav-ext-module"; fi if [ "$DAV_EXT" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/nginx-dav-ext-module"; fi
if [ "$FANCYINDEX" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/ngx-fancyindex"; fi if [ "$FANCYINDEX" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/ngx-fancyindex"; fi
if [ "$GEOIP2" = 1 ]; then BUILD_MODULES="${BUILD_MODULES} --add-module=./lib/ngx_http_geoip2_module"; fi
auto/configure \ auto/configure \
--with-cc-opt="-DTCP_FASTOPEN=23 ${BUILD_BIT}${BUILD_LTO} -g -O3 -march=native -fstack-protector-strong -fuse-ld=gold -fuse-linker-plugin --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wno-strict-aliasing -Wp,-D_FORTIFY_SOURCE=2 -gsplit-dwarf -DNGX_HTTP_HEADERS" \ --with-cc-opt="-DTCP_FASTOPEN=23 ${BUILD_BIT}${BUILD_LTO} -g -O3 -march=native -fstack-protector-strong -fuse-ld=gold -fuse-linker-plugin --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wno-strict-aliasing -Wp,-D_FORTIFY_SOURCE=2 -gsplit-dwarf -DNGX_HTTP_HEADERS" \
@@ -122,7 +123,6 @@ auto/configure \
--with-http_stub_status_module \ --with-http_stub_status_module \
--with-http_flv_module \ --with-http_flv_module \
--with-http_mp4_module \ --with-http_mp4_module \
--with-http_geoip_module \
--with-http_gunzip_module \ --with-http_gunzip_module \
--with-http_slice_module \ --with-http_slice_module \
--with-http_gzip_static_module \ --with-http_gzip_static_module \
@@ -142,7 +142,6 @@ auto/configure \
--with-http_v2_module \ --with-http_v2_module \
--with-http_v2_hpack_enc \ --with-http_v2_hpack_enc \
--with-stream_ssl_module \ --with-stream_ssl_module \
--with-stream_geoip_module \
--with-stream_realip_module \ --with-stream_realip_module \
--with-stream_ssl_preread_module \ --with-stream_ssl_preread_module \
--add-module=./lib/ngx_devel_kit \ --add-module=./lib/ngx_devel_kit \
+3
View File
@@ -44,6 +44,9 @@ DAV_EXT=1
### fancyindex ### fancyindex
FANCYINDEX=1 FANCYINDEX=1
### GEOIP2
GEOIP2=1
########################## ##########################
### nginx install path ### ### nginx install path ###
########################## ##########################
+1 -9
View File
@@ -180,15 +180,7 @@ ngx_http_rewrite_handler(ngx_http_request_t *r)
code(e); code(e);
} }
if (e->status < NGX_HTTP_BAD_REQUEST) { return e->status;
return e->status;
}
if (r->err_status == 0) {
return e->status;
}
return r->err_status;
} }
+26 -24
View File
@@ -962,7 +962,7 @@ ngx_http_process_request_line(ngx_event_t *rev)
n = ngx_http_read_request_header(r); n = ngx_http_read_request_header(r);
if (n == NGX_AGAIN || n == NGX_ERROR) { if (n == NGX_AGAIN || n == NGX_ERROR) {
return; break;
} }
} }
@@ -987,7 +987,7 @@ ngx_http_process_request_line(ngx_event_t *rev)
} }
if (ngx_http_process_request_uri(r) != NGX_OK) { if (ngx_http_process_request_uri(r) != NGX_OK) {
return; break;
} }
if (r->schema_end) { if (r->schema_end) {
@@ -1006,16 +1006,16 @@ ngx_http_process_request_line(ngx_event_t *rev)
ngx_log_error(NGX_LOG_INFO, c->log, 0, ngx_log_error(NGX_LOG_INFO, c->log, 0,
"client sent invalid host in request line"); "client sent invalid host in request line");
ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
return; break;
} }
if (rc == NGX_ERROR) { if (rc == NGX_ERROR) {
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
return; break;
} }
if (ngx_http_set_virtual_server(r, &host) == NGX_ERROR) { if (ngx_http_set_virtual_server(r, &host) == NGX_ERROR) {
return; break;
} }
r->headers_in.server = host; r->headers_in.server = host;
@@ -1027,11 +1027,11 @@ ngx_http_process_request_line(ngx_event_t *rev)
&& ngx_http_set_virtual_server(r, &r->headers_in.server) && ngx_http_set_virtual_server(r, &r->headers_in.server)
== NGX_ERROR) == NGX_ERROR)
{ {
return; break;
} }
ngx_http_process_request(r); ngx_http_process_request(r);
return; break;
} }
@@ -1040,7 +1040,7 @@ ngx_http_process_request_line(ngx_event_t *rev)
!= NGX_OK) != NGX_OK)
{ {
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
return; break;
} }
c->log->action = "reading client request headers"; c->log->action = "reading client request headers";
@@ -1048,7 +1048,7 @@ ngx_http_process_request_line(ngx_event_t *rev)
rev->handler = ngx_http_process_request_headers; rev->handler = ngx_http_process_request_headers;
ngx_http_process_request_headers(rev); ngx_http_process_request_headers(rev);
return; break;
} }
if (rc != NGX_AGAIN) { if (rc != NGX_AGAIN) {
@@ -1065,7 +1065,7 @@ ngx_http_process_request_line(ngx_event_t *rev)
(r->http_connection->ssl && clcf->strict_sni && clcf->strict_sni_header) ? ngx_http_terminate_request(r, 0) : ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); (r->http_connection->ssl && clcf->strict_sni && clcf->strict_sni_header) ? ngx_http_terminate_request(r, 0) : ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
} }
return; break;
} }
/* NGX_AGAIN: a request line parsing is still incomplete */ /* NGX_AGAIN: a request line parsing is still incomplete */
@@ -1076,7 +1076,7 @@ ngx_http_process_request_line(ngx_event_t *rev)
if (rv == NGX_ERROR) { if (rv == NGX_ERROR) {
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
return; break;
} }
if (rv == NGX_DECLINED) { if (rv == NGX_DECLINED) {
@@ -1086,10 +1086,12 @@ ngx_http_process_request_line(ngx_event_t *rev)
ngx_log_error(NGX_LOG_INFO, c->log, 0, ngx_log_error(NGX_LOG_INFO, c->log, 0,
"client sent too long URI"); "client sent too long URI");
ngx_http_finalize_request(r, NGX_HTTP_REQUEST_URI_TOO_LARGE); ngx_http_finalize_request(r, NGX_HTTP_REQUEST_URI_TOO_LARGE);
return; break;
} }
} }
} }
ngx_http_run_posted_requests(c);
} }
@@ -1251,7 +1253,7 @@ ngx_http_process_request_headers(ngx_event_t *rev)
if (rv == NGX_ERROR) { if (rv == NGX_ERROR) {
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
return; break;
} }
if (rv == NGX_DECLINED) { if (rv == NGX_DECLINED) {
@@ -1264,7 +1266,7 @@ ngx_http_process_request_headers(ngx_event_t *rev)
"client sent too large request"); "client sent too large request");
ngx_http_finalize_request(r, ngx_http_finalize_request(r,
NGX_HTTP_REQUEST_HEADER_TOO_LARGE); NGX_HTTP_REQUEST_HEADER_TOO_LARGE);
return; break;
} }
len = r->header_in->end - p; len = r->header_in->end - p;
@@ -1279,14 +1281,14 @@ ngx_http_process_request_headers(ngx_event_t *rev)
ngx_http_finalize_request(r, ngx_http_finalize_request(r,
NGX_HTTP_REQUEST_HEADER_TOO_LARGE); NGX_HTTP_REQUEST_HEADER_TOO_LARGE);
return; break;
} }
} }
n = ngx_http_read_request_header(r); n = ngx_http_read_request_header(r);
if (n == NGX_AGAIN || n == NGX_ERROR) { if (n == NGX_AGAIN || n == NGX_ERROR) {
return; break;
} }
} }
@@ -1316,7 +1318,7 @@ ngx_http_process_request_headers(ngx_event_t *rev)
h = ngx_list_push(&r->headers_in.headers); h = ngx_list_push(&r->headers_in.headers);
if (h == NULL) { if (h == NULL) {
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
return; break;
} }
h->hash = r->header_hash; h->hash = r->header_hash;
@@ -1332,7 +1334,7 @@ ngx_http_process_request_headers(ngx_event_t *rev)
h->lowcase_key = ngx_pnalloc(r->pool, h->key.len); h->lowcase_key = ngx_pnalloc(r->pool, h->key.len);
if (h->lowcase_key == NULL) { if (h->lowcase_key == NULL) {
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
return; break;
} }
if (h->key.len == r->lowcase_index) { if (h->key.len == r->lowcase_index) {
@@ -1346,7 +1348,7 @@ ngx_http_process_request_headers(ngx_event_t *rev)
h->lowcase_key, h->key.len); h->lowcase_key, h->key.len);
if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {
return; break;
} }
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -1370,12 +1372,12 @@ ngx_http_process_request_headers(ngx_event_t *rev)
rc = ngx_http_process_request_header(r); rc = ngx_http_process_request_header(r);
if (rc != NGX_OK) { if (rc != NGX_OK) {
return; break;
} }
ngx_http_process_request(r); ngx_http_process_request(r);
return; break;
} }
if (rc == NGX_AGAIN) { if (rc == NGX_AGAIN) {
@@ -1391,8 +1393,10 @@ ngx_http_process_request_headers(ngx_event_t *rev)
"client sent invalid header line"); "client sent invalid header line");
ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
return; break;
} }
ngx_http_run_posted_requests(c);
} }
@@ -1954,8 +1958,6 @@ ngx_http_process_request(ngx_http_request_t *r)
r->read_event_handler = ngx_http_block_reading; r->read_event_handler = ngx_http_block_reading;
ngx_http_handler(r); ngx_http_handler(r);
ngx_http_run_posted_requests(c);
} }
+14 -4
View File
@@ -2683,11 +2683,13 @@ error:
if (rc == NGX_ABORT) { if (rc == NGX_ABORT) {
/* header handler has already finalized request */ /* header handler has already finalized request */
ngx_http_run_posted_requests(fc);
return NULL; return NULL;
} }
if (rc == NGX_DECLINED) { if (rc == NGX_DECLINED) {
ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
ngx_http_run_posted_requests(fc);
return NULL; return NULL;
} }
@@ -3752,18 +3754,22 @@ ngx_http_v2_construct_cookie_header(ngx_http_request_t *r)
static void static void
ngx_http_v2_run_request(ngx_http_request_t *r) ngx_http_v2_run_request(ngx_http_request_t *r)
{ {
ngx_connection_t *fc;
fc = r->connection;
if (ngx_http_v2_construct_request_line(r) != NGX_OK) { if (ngx_http_v2_construct_request_line(r) != NGX_OK) {
return; goto failed;
} }
if (ngx_http_v2_construct_cookie_header(r) != NGX_OK) { if (ngx_http_v2_construct_cookie_header(r) != NGX_OK) {
return; goto failed;
} }
r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE; r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE;
if (ngx_http_process_request_header(r) != NGX_OK) { if (ngx_http_process_request_header(r) != NGX_OK) {
return; goto failed;
} }
if (r->headers_in.content_length_n > 0 && r->stream->in_closed) { if (r->headers_in.content_length_n > 0 && r->stream->in_closed) {
@@ -3773,7 +3779,7 @@ ngx_http_v2_run_request(ngx_http_request_t *r)
r->stream->skip_data = 1; r->stream->skip_data = 1;
ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
return; goto failed;
} }
if (r->headers_in.content_length_n == -1 && !r->stream->in_closed) { if (r->headers_in.content_length_n == -1 && !r->stream->in_closed) {
@@ -3781,6 +3787,10 @@ ngx_http_v2_run_request(ngx_http_request_t *r)
} }
ngx_http_process_request(r); ngx_http_process_request(r);
failed:
ngx_http_run_posted_requests(fc);
} }