+ // Extract destination information
+ var crurl=clientrequest.url;
+ var crhost=clientrequest.headers['host'];
+ var crproto=clientrequest.headers['x-forwarded-proto'];
+
+ if (debug) {
+ console.log("crurl: "+crurl)
+ console.log("crhost: "+crhost)
+ console.log("crproto: "+crproto)
+ }
+
+ // If this server is running behind a proxy (like istio envoy proxy) then the 'clientrequest.url'
+ // only contains the path component (i.e /test ). The host name and port is included in the
+ // 'host' header and the protocol (http/https) is in the header 'x-forwarded-proto'.
+ // In case of istio - https to a pod over mTLS does not seem to work. Only http.
+ // Othewise, if no front proxy, the full url is included in the 'clientrequest.url'
+ if (crproto != undefined) {
+ crurl=crproto+"://"+crhost+crurl
+ if (debug) {
+ console.log(" Constructed url: "+crurl)
+ }
+ } else if (crurl.startsWith('/')) {
+ console.log("Catched bad url in http request: "+crurl)