Skip to content

Commit e86974e

Browse files
committed
Re-use existing Jespa-Connection-Id header value
+ If upstream proxy or ingress has already set this header on the request, our standard proxy include should re-use the same value. Otherwise, set to `$remote_addr:$remote_port` as before.
1 parent c9a1e2b commit e86974e

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

includes/xh-proxy.conf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ proxy_set_header X-Forwarded-Host $host;
77
proxy_set_header X-Forwarded-Server $host;
88
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
99

10-
# Required for NTLM SSO when using Jespa
11-
proxy_set_header Jespa-Connection-Id $remote_addr:$remote_port;
10+
# Required for NTLM SSO when using Jespa - should contain client remote_addr:remote_port to uniquely
11+
# ID client connection across multi-step NTLM handshake. Var is set in xh.conf, see notes there.
12+
proxy_set_header Jespa-Connection-Id $xh_jespa_connection_id;
1213

1314
# Additional SSL support
1415
proxy_set_header X-Forwarded-Proto $scheme;

xh.conf

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ gzip_min_length 1000;
66
gzip_proxied any;
77
gzip_types application/json application/javascript text/css text/javascript;
88

9+
# Increase client max body size to allow for larger uploads
10+
client_max_body_size 20m;
11+
12+
# Increase proxy headers hash size due to our use of proxy_set_header - as per nginx msg in log.
13+
proxy_headers_hash_max_size 1024;
14+
915
# Convenience map to specify caching expiry by request type (use in expires directive as below)
1016
map $sent_http_content_type $expires {
1117
default off;
@@ -16,9 +22,6 @@ map $sent_http_content_type $expires {
1622
text/html epoch;
1723
}
1824

19-
# Increase client max body size to allow for larger uploads
20-
client_max_body_size 20m;
21-
2225
# Set $is_desktop and $is_mobile variables for simple UA-based sniffing.
2326
# This was snagged from https://gist.github.com/perusio/1326701 and is not guaranteed by any means
2427
# to be perfect or exhaustive. Apps should use with care - we can tune if we have real-world cases
@@ -35,6 +38,19 @@ map $is_desktop $is_mobile {
3538
0 1;
3639
}
3740

41+
# Set new $xh_jespa_connection_id for use in xh-proxy include, where the resulting value is
42+
# used to add/replace a Jespa-Connection-Id header. If request arrives with a Jespa-Connection-Id
43+
# header already set, this map will re-use that same value: the incoming header is assumed to
44+
# have been set by an upstream proxy or k8s ingress and to contain the actual client addr and port.
45+
# Otherwise, we create the ID with the addr and port we know about here.
46+
map $http_jespa_connection_id $xh_jespa_connection_id {
47+
volatile;
48+
default $http_jespa_connection_id;
49+
50+
"" $remote_addr:$remote_port;
51+
}
52+
53+
3854
# App-level Dockerfiles must copy in an appropriate conf with server directives such as the below.
3955

4056
#server {

0 commit comments

Comments
 (0)