From 271e1c4a98f20ab67c82ed8ea1e19041478dc8bc Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 13:41:58 +0000 Subject: [PATCH 01/15] Improve nginx params --- config/nginx.conf | 6 ++++++ config/status.conf | 14 ++++++++++++++ docker-compose.yml | 4 ++-- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 config/status.conf diff --git a/config/nginx.conf b/config/nginx.conf index 8aa3d50..b748ecb 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -1,9 +1,15 @@ +# Automatically use all available CPU cores +worker_processes: auto; + events { worker_connections 100000; } http { + log_format upstreamlog '[$time_local] $remote_addr - $remote_user - $server_name $host to: $upstream_addr: $request $status upstream_response_time $upstream_response_time msec $msec request_time $request_time'; + access_log /var/log/nginx/access.log upstreamlog; + limit_req_zone $binary_remote_addr zone=one:10m rate=100r/s; client_max_body_size 5M; diff --git a/config/status.conf b/config/status.conf new file mode 100644 index 0000000..4f16c2a --- /dev/null +++ b/config/status.conf @@ -0,0 +1,14 @@ +server { + listen localhost; + server_name status.localhost; + keepalive_timeout 0; + + access_log off; + + allow 127.0.0.1; + deny all; + + location /nginx_status { + stub_status on; + } +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d209e90..7ee2f7e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -47,5 +47,5 @@ services: logging: driver: "json-file" options: - max-file: "5" - max-size: "200m" + max-file: "10" + max-size: "2000m" From 23b390dd1b756e05283d609bc0ded40d270f10bd Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 14:01:00 +0000 Subject: [PATCH 02/15] Improve nginx params --- config/nginx.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/nginx.conf b/config/nginx.conf index b748ecb..c5a1982 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -1,10 +1,11 @@ -# Automatically use all available CPU cores -worker_processes: auto; events { worker_connections 100000; } +# Automatically use all available CPU cores +worker_processes: 4; + http { log_format upstreamlog '[$time_local] $remote_addr - $remote_user - $server_name $host to: $upstream_addr: $request $status upstream_response_time $upstream_response_time msec $msec request_time $request_time'; From 57224067c6ec17edaec64874c19eab235e616dd1 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 15:22:46 +0000 Subject: [PATCH 03/15] Modify nginx params --- config/nginx.conf | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/config/nginx.conf b/config/nginx.conf index c5a1982..9244a23 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -1,10 +1,8 @@ - events { worker_connections 100000; } -# Automatically use all available CPU cores -worker_processes: 4; +worker_processes auto; http { From 181aba2d057d25188d24fdc00583f2b99362bdec Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 15:31:16 +0000 Subject: [PATCH 04/15] Modify nginx log format --- config/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/nginx.conf b/config/nginx.conf index 9244a23..adf5c40 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -6,7 +6,7 @@ worker_processes auto; http { - log_format upstreamlog '[$time_local] $remote_addr - $remote_user - $server_name $host to: $upstream_addr: $request $status upstream_response_time $upstream_response_time msec $msec request_time $request_time'; + log_format upstreamlog '[$time_local] $remote_addr - $host` to: $upstream_addr: $request - $status - upstream_response_time $upstream_response_time msec $msec request_time $request_time ($http_referer $http_user_agent)'; access_log /var/log/nginx/access.log upstreamlog; limit_req_zone $binary_remote_addr zone=one:10m rate=100r/s; From d112680b9463b72a053a1ef2a25021d520b0f774 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 15:50:57 +0000 Subject: [PATCH 05/15] Tune nginx log params --- config/nginx.conf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/nginx.conf b/config/nginx.conf index adf5c40..3c66fa5 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -5,8 +5,7 @@ events { worker_processes auto; http { - - log_format upstreamlog '[$time_local] $remote_addr - $host` to: $upstream_addr: $request - $status - upstream_response_time $upstream_response_time msec $msec request_time $request_time ($http_referer $http_user_agent)'; + log_format upstreamlog '[$time_local] $request - $status - $host - $remote_addr - to: $upstream_addr - urt: $upstream_response_time msec: $msec req_t: $request_time ($http_referer $http_user_agent)'; access_log /var/log/nginx/access.log upstreamlog; limit_req_zone $binary_remote_addr zone=one:10m rate=100r/s; From 61a941df7b53853ef4f94fb781e8bbc12908e521 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 16:01:26 +0000 Subject: [PATCH 06/15] Change docker logs size --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7ee2f7e..16866ed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -47,5 +47,5 @@ services: logging: driver: "json-file" options: - max-file: "10" - max-size: "2000m" + max-file: "200" + max-size: "500m" From 74011f0d8d80f21348f4ad91f938f91bdc8a1908 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 16:07:34 +0000 Subject: [PATCH 07/15] Add status config --- config/nginx.conf | 3 ++- docker-compose.yml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/nginx.conf b/config/nginx.conf index 3c66fa5..097ac10 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -5,7 +5,7 @@ events { worker_processes auto; http { - log_format upstreamlog '[$time_local] $request - $status - $host - $remote_addr - to: $upstream_addr - urt: $upstream_response_time msec: $msec req_t: $request_time ($http_referer $http_user_agent)'; + log_format upstreamlog '[$time_local] $request $status $host - $remote_addr to: $upstream_addr - urt: $upstream_response_time msec: $msec req_t: $request_time ($http_referer $http_user_agent)'; access_log /var/log/nginx/access.log upstreamlog; limit_req_zone $binary_remote_addr zone=one:10m rate=100r/s; @@ -41,4 +41,5 @@ http { } include /etc/nginx/conf/upstreams/*.conf; + include /etc/nginx/status.conf; } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 16866ed..6f09441 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -43,6 +43,7 @@ services: - ./data:/data - ./www:/usr/share/nginx/www/files - ./config/nginx.conf:/etc/nginx/nginx.conf:ro + - ./config/status.conf:/etc/nginx/status.conf:ro - ./conf:/etc/nginx/conf/ logging: driver: "json-file" From 14ec43f5868ca42c979176cd5a225018b3641d2a Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 16:11:04 +0000 Subject: [PATCH 08/15] Add status config --- config/nginx.conf | 8 +++++++- docker-compose.yml | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/config/nginx.conf b/config/nginx.conf index 097ac10..e62a7eb 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -37,9 +37,15 @@ http { root /usr/share/nginx/www; } + location /nginx_status { + stub_status on; + access_log off; + allow 127.0.0.1; + deny all; + } + include /etc/nginx/conf/chains/*.conf; } include /etc/nginx/conf/upstreams/*.conf; - include /etc/nginx/status.conf; } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 6f09441..16866ed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -43,7 +43,6 @@ services: - ./data:/data - ./www:/usr/share/nginx/www/files - ./config/nginx.conf:/etc/nginx/nginx.conf:ro - - ./config/status.conf:/etc/nginx/status.conf:ro - ./conf:/etc/nginx/conf/ logging: driver: "json-file" From ece91dbb8258e39f7ec18cbb70b60db11a2e53c4 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 16:20:09 +0000 Subject: [PATCH 09/15] Add status config --- config/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/nginx.conf b/config/nginx.conf index e62a7eb..bd810e0 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -40,7 +40,7 @@ http { location /nginx_status { stub_status on; access_log off; - allow 127.0.0.1; + allow 0.0.0.0; deny all; } From dad7b4443dce58ab7158f416fafcb9e3582ada52 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 16:46:49 +0000 Subject: [PATCH 10/15] Add status config --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 16866ed..55d3b40 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ services: network-ui: image: network-ui:latest container_name: network_ui + network_mode: host build: context: ./network-ui dockerfile: Dockerfile @@ -36,6 +37,7 @@ services: nginx: image: nginx:1.20.2 container_name: proxy_nginx + network_mode: host ports: - "80:80" - "443:443" From dbe45d5c4967592347e8a4d23da6890dd7e5b8b9 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 16:50:28 +0000 Subject: [PATCH 11/15] Remove ports --- docker-compose.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 55d3b40..ac9e027 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,8 +7,6 @@ services: build: context: ./network-ui dockerfile: Dockerfile - ports: - - "5001:5001" logging: driver: "json-file" options: @@ -38,9 +36,6 @@ services: image: nginx:1.20.2 container_name: proxy_nginx network_mode: host - ports: - - "80:80" - - "443:443" volumes: - ./data:/data - ./www:/usr/share/nginx/www/files From f1e44901c7c45ec428ea51469adfc484b8c08716 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 16:53:03 +0000 Subject: [PATCH 12/15] Remove ports --- config/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/nginx.conf b/config/nginx.conf index bd810e0..f83367c 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -26,7 +26,7 @@ http { location / { proxy_http_version 1.1; - proxy_pass http://network-ui:5001/; + proxy_pass http://0.0.0.0:5001/; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; From 9729c56d8c111b05d8fba832f7847cdcd158adc5 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 16:59:01 +0000 Subject: [PATCH 13/15] Remove ports --- config/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/nginx.conf b/config/nginx.conf index f83367c..6fe719a 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -40,7 +40,7 @@ http { location /nginx_status { stub_status on; access_log off; - allow 0.0.0.0; + allow 127.0.0.1; deny all; } From 3f5a72af5ee5875e5bcdc261f487aeb117db0882 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 17:03:21 +0000 Subject: [PATCH 14/15] Remove unused status file --- config/status.conf | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 config/status.conf diff --git a/config/status.conf b/config/status.conf deleted file mode 100644 index 4f16c2a..0000000 --- a/config/status.conf +++ /dev/null @@ -1,14 +0,0 @@ -server { - listen localhost; - server_name status.localhost; - keepalive_timeout 0; - - access_log off; - - allow 127.0.0.1; - deny all; - - location /nginx_status { - stub_status on; - } -} \ No newline at end of file From f09e108f336e44eba3937bf5e2dfe7d8b6def90e Mon Sep 17 00:00:00 2001 From: Dmytro Date: Thu, 17 Nov 2022 17:16:50 +0000 Subject: [PATCH 15/15] Change proxy path to localhost --- config/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/nginx.conf b/config/nginx.conf index 6fe719a..f1d6887 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -26,7 +26,7 @@ http { location / { proxy_http_version 1.1; - proxy_pass http://0.0.0.0:5001/; + proxy_pass http://localhost:5001/; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host;