Skip to content

Commit

Permalink
Issue #1661: Adding nginx request_id in logging
Browse files Browse the repository at this point in the history
and passing request id upstream

Signed-off-by: Rajesh Rajendran <[email protected]>
  • Loading branch information
rjshrjndrn committed Jul 9, 2020
1 parent 462b63e commit ae985b3
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion kubernetes/helm_charts/core/nginx-public-ingress/values.j2
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ proxyconfig: |
local h = ngx.req.get_headers()
ngx.log(ngx.WARN, "Deviceid: ", h["x-device-id"], " Channelid: ", h["x-channel-id"], " Appid: ", h["x-app-id"])
}
proxy_set_header X-Request-ID $request_id;
proxy_pass http://kong;
}
location /v3/device/register {
proxy_set_header X-Request-ID $request_id;
proxy_pass http://kong;
proxy_set_header Connection "";
rewrite ^/v3/device/register/(.*) /v3/device/register/$1 break;
Expand Down Expand Up @@ -193,11 +195,13 @@ proxyconfig: |
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://player;
}
location /auth/ {
rewrite ^/auth/(.*) /auth/$1 break;
proxy_set_header Connection "";
proxy_set_header X-Request-ID $request_id;
proxy_pass http://keycloak;
proxy_set_header Host $host;
proxy_set_header X-Real-IP {{ nginx_client_public_ip_header | d('$remote_addr') }};
Expand Down Expand Up @@ -228,6 +232,7 @@ proxyconfig: |
proxy_send_timeout 60;
proxy_read_timeout 70;
proxy_http_version 1.1;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://player;
}
# This is Caching mechanism for POST requests
Expand All @@ -254,6 +259,7 @@ proxyconfig: |
proxy_send_timeout 60;
proxy_read_timeout 70;
proxy_http_version 1.1;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://kong;
}

Expand All @@ -279,6 +285,7 @@ proxyconfig: |
proxy_send_timeout 60;
proxy_read_timeout 70;
proxy_http_version 1.1;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://kong;
}

Expand Down Expand Up @@ -313,6 +320,7 @@ proxyconfig: |
local h = ngx.req.get_headers()
ngx.log(ngx.WARN, "Deviceid: ", h["x-device-id"], " Channelid: ", h["x-channel-id"], " Appid: ", h["x-app-id"])
}
proxy_set_header X-Request-ID $request_id;
proxy_pass http://kong;
}
# Oauth2 config
Expand All @@ -321,6 +329,7 @@ proxyconfig: |
proxy_set_header X-Real-IP {{ nginx_client_public_ip_header | d('$remote_addr') }};
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Auth-Request-Redirect $request_uri;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://oauth2-proxy.logging.svc.cluster.local;
}
location = /oauth2/auth {
Expand All @@ -330,6 +339,7 @@ proxyconfig: |
# nginx auth_request includes headers but not body
proxy_set_header Content-Length "";
proxy_pass_request_body off;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://oauth2-proxy.logging.svc.cluster.local;
}
location /dashboard/ {
Expand All @@ -346,10 +356,12 @@ proxyconfig: |
# if you enabled --cookie-refresh, this is needed for it to work with auth_request
auth_request_set $auth_cookie $upstream_http_set_cookie;
add_header Set-Cookie $auth_cookie;
proxy_set_header X-Request-ID $request_id;
proxy_pass $target;
}
location /grafana/ {
rewrite ^/grafana/(.*) /$1 break;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://prometheus-operator-grafana.monitoring.svc.cluster.local;
}
location /encryption/ {
Expand All @@ -361,6 +373,7 @@ proxyconfig: |
proxy_send_timeout 30;
proxy_read_timeout 40;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://encryption;
}
location /badging/ {
Expand All @@ -372,6 +385,7 @@ proxyconfig: |
proxy_send_timeout 30;
proxy_read_timeout 40;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://badger-service.{{ namespace }}.svc.cluster.local:8004;
}
location ~* ^/assets/public/(.*) {
Expand Down Expand Up @@ -408,6 +422,7 @@ proxyconfig: |
proxy_intercept_errors on;
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods GET;
proxy_set_header X-Request-ID $request_id;
proxy_pass https://$bucket/$url_full;
}
location ~* ^/content/preview/(.*) {
Expand Down Expand Up @@ -440,6 +455,7 @@ proxyconfig: |
proxy_intercept_errors on;
add_header Access-Control-Allow-Origin "*" ;
add_header Access-Control-Allow-Methods GET;
proxy_set_header X-Request-ID $request_id;
proxy_pass https://$s3_bucket/v3/preview/$url_full;
}

Expand All @@ -454,6 +470,7 @@ proxyconfig: |
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://player;
}
location ~* ^/content-editor/(.*) {
Expand Down Expand Up @@ -486,6 +503,7 @@ proxyconfig: |
proxy_intercept_errors on;
add_header Access-Control-Allow-Origin "*" ;
add_header Access-Control-Allow-Methods GET;
proxy_set_header X-Request-ID $request_id;
proxy_pass https://$s3_bucket/content-editor/$url_full;
}
location ~* ^/collection-editor/(.*) {
Expand Down Expand Up @@ -518,6 +536,7 @@ proxyconfig: |
proxy_intercept_errors on;
add_header Access-Control-Allow-Origin "*" ;
add_header Access-Control-Allow-Methods GET;
proxy_set_header X-Request-ID $request_id;
proxy_pass https://$s3_bucket/collection-editor/$url_full;
}
location ~* ^/generic-editor/(.*) {
Expand Down Expand Up @@ -550,6 +569,7 @@ proxyconfig: |
proxy_intercept_errors on;
add_header Access-Control-Allow-Origin "*" ;
add_header Access-Control-Allow-Methods GET;
proxy_set_header X-Request-ID $request_id;
proxy_pass https://$s3_bucket/generic-editor/$url_full;
}
location ~* ^/content-plugins/(.*) {
Expand Down Expand Up @@ -586,6 +606,7 @@ proxyconfig: |
proxy_intercept_errors on;
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods GET;
proxy_set_header X-Request-ID $request_id;
proxy_pass https://$s3_bucket/content-plugins/$url_full;
}
location /thirdparty {
Expand All @@ -608,6 +629,7 @@ proxyconfig: |
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://player;
}
location ~* ^/desktop/(.*) {
Expand Down Expand Up @@ -644,6 +666,7 @@ proxyconfig: |
proxy_intercept_errors on;
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods GET;
proxy_set_header X-Request-ID $request_id;
proxy_pass https://$offline_bucket/$url_full;
}
location / {
Expand All @@ -657,9 +680,11 @@ proxyconfig: |
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://player;
}
location /v3/device/register {
proxy_set_header X-Request-ID $request_id;
proxy_pass http://kong;
proxy_set_header Connection "";
rewrite ^/v3/device/register/(.*) /v3/device/register/$1 break;
Expand All @@ -672,6 +697,7 @@ proxyconfig: |
proxy_http_version 1.1;
}
location /action/data/v3/metrics {
proxy_set_header X-Request-ID $request_id;
proxy_pass http://kong;
proxy_set_header Connection "";
rewrite ^/action/data/v3/metrics/(.*) /data/v3/metrics/$1 break;
Expand Down Expand Up @@ -699,6 +725,7 @@ proxyconfig: |
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://player;
}

Expand All @@ -723,6 +750,7 @@ proxyconfig: |
proxy_send_timeout 60;
proxy_read_timeout 70;
proxy_http_version 1.1;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://kong;
}

Expand Down Expand Up @@ -775,7 +803,7 @@ nginxconfig: |
log_format main '{{ nginx_client_public_ip_header | d('$remote_addr') }} - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'$request_time $upstream_response_time $pipe'
'"$http_referer" "$http_user_agent"';
'"$http_referer" "$http_user_agent" $request_id';

access_log /var/log/nginx/access.log main;

Expand Down Expand Up @@ -908,6 +936,7 @@ keycloakconf: |
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://player;
}

Expand All @@ -917,6 +946,7 @@ keycloakconf: |
location /auth/ {
set $target {{ keycloak_url }};
rewrite ^/auth/(.*) /auth/$1 break;
proxy_set_header X-Request-ID $request_id;
proxy_pass $target;
proxy_set_header Host $host;
proxy_set_header X-Real-IP {{ nginx_client_public_ip_header | d('$remote_addr') }};
Expand All @@ -936,6 +966,7 @@ keycloakconf: |
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_set_header X-Request-ID $request_id;
proxy_pass http://player;
}
}
Expand Down

0 comments on commit ae985b3

Please sign in to comment.