Skip to content

Commit

Permalink
fix: redis routine
Browse files Browse the repository at this point in the history
  • Loading branch information
mhf-ir committed Jun 16, 2023
1 parent 81fd8ff commit 746f3d4
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 32 deletions.
8 changes: 4 additions & 4 deletions Dockerfile.nginx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ FROM ghcr.io/aasaam/nginx-extra:latest
ENV ASM_NGX_EXTRA_WORKER_PROCESSES="auto" \
ASM_NGX_EXTRA_WORKER_RLIMIT_NOFILE="80000" \
ASM_NGX_EXTRA_ERROR_LOG_LEVEL="warn" \
ASM_NGX_EXTRA_WORKER_CONNECTIONS="2048" \
ASM_NGX_EXTRA_WORKER_CONNECTIONS="4096" \
ASM_NGX_EXTRA_CLIENT_BODY_TIMEOUT="4s" \
ASM_NGX_EXTRA_CLIENT_HEADER_TIMEOUT="4s" \
ASM_NGX_EXTRA_KEEPALIVE_REQUESTS="20480" \
ASM_NGX_EXTRA_KEEPALIVE_TIMEOUT="30" \
ASM_NGX_EXTRA_KEEPALIVE_TIMEOUT="10" \
ASM_NGX_EXTRA_SEND_TIMEOUT="2" \
ASM_NGX_EXTRA_CLIENT_BODY_BUFFER_SIZE="256k" \
ASM_NGX_EXTRA_CLIENT_HEADER_BUFFER_SIZE="2k" \
Expand All @@ -16,8 +16,8 @@ ENV ASM_NGX_EXTRA_WORKER_PROCESSES="auto" \
ASM_NGX_EXTRA_CLIENT_MAX_BODY_SIZE="2m" \
ASM_NGX_EXTRA_PROXY_CACHE_FAST_SIZE="128m" \
ASM_NGX_EXTRA_ACCESS_LOG_COMMENT="#" \
ASM_NGX_EXTRA_SSL_PROFILE="legacy" \
ASM_NGX_EXTRA_UPSTREAM="http://analytics-collector-producer:4000"
ASM_NGX_EXTRA_SSL_PROFILE="legacy"
ADD nginx/nginx.conf /template/nginx.conf
ADD nginx/upstream.conf /upstream.conf
ADD nginx/cert /cert
41 changes: 19 additions & 22 deletions http_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,30 +208,27 @@ func httpRecord(
)
}

_, redErr := redisClient.LPush(context.Background(), redisKeyRecords, recordBytes).Result()
go func() {
_, redErr := redisClient.LPush(context.Background(), redisKeyRecords, recordBytes).Result()
if redErr != nil {
blockErr := errorInternalDependencyFailed
blockErr.debug = redErr.Error()

if redErr != nil {
blockErr := errorInternalDependencyFailed
blockErr.debug = redErr.Error()

conf.getLogger().
Error().
Str("part", "finalize").
Str("on", blockErr.msg).
Str("error", blockErr.debug).
Str("ip", ip.String()).
Str("method", c.Method()).
Str("path", c.Path()).
Str("qs", string(c.Request().URI().QueryString())).
Str("body", string(c.Request().Body())).
Strs("headers", rawHeaderLog(c.Request().Header.RawHeaders())).
Send()
conf.getLogger().
Error().
Str("part", "finalize").
Str("on", blockErr.msg).
Str("error", blockErr.debug).
Str("ip", ip.String()).
Str("method", c.Method()).
Str("path", c.Path()).
Str("qs", string(c.Request().URI().QueryString())).
Str("body", string(c.Request().Body())).
Strs("headers", rawHeaderLog(c.Request().Header.RawHeaders())).
Send()

return httpErrorResponse(
c,
blockErr,
)
}
}
}()

if record.isImage() {
return responseImage(c)
Expand Down
15 changes: 9 additions & 6 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ http {

include /.defaults/http.conf;

include /upstream.conf;

client_body_timeout ${ASM_NGX_EXTRA_CLIENT_BODY_TIMEOUT};
client_header_timeout ${ASM_NGX_EXTRA_CLIENT_HEADER_TIMEOUT};
keepalive_requests ${ASM_NGX_EXTRA_KEEPALIVE_REQUESTS};
Expand All @@ -38,11 +40,14 @@ http {
proxy_buffering on;
proxy_buffers 16 128k;
proxy_buffer_size 128k;
proxy_cache_methods GET HEAD;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504 http_429;
proxy_http_version 1.1;
proxy_read_timeout 20s;
proxy_cache_valid 200 301 4m;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504 http_429;
proxy_cache_methods GET HEAD;
proxy_cache_valid 200 206 301 10m;
proxy_cache_lock_timeout 0s;
proxy_cache_lock_age 60s;
proxy_cache_lock on;
proxy_request_buffering off;

# proxy cache
Expand Down Expand Up @@ -83,8 +88,6 @@ http {
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA;
ssl_prefer_server_ciphers on;



location = /stub_status {
allow 127.0.0.0/8;
allow 192.168.0.0/16;
Expand Down Expand Up @@ -131,7 +134,7 @@ http {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_cache PROXY_CACHE_FAST;
proxy_pass ${ASM_NGX_EXTRA_UPSTREAM};
proxy_pass http://producers;

${ASM_NGX_EXTRA_ACCESS_LOG_COMMENT} access_log /dev/stdout http_jsonlog if=$loggable;
}
Expand Down
8 changes: 8 additions & 0 deletions nginx/upstream.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
upstream producers {
server analytics-collector-producer:4000;
# server analytics-collector-producer-0:4000;
# server analytics-collector-producer-1:4000;
# server analytics-collector-producer-2:4000;
# server analytics-collector-producer-3:4000;
# server analytics-collector-producer-4:4000;
}

0 comments on commit 746f3d4

Please sign in to comment.