Skip to content

Commit 6dfcd12

Browse files
Update readme with proxy in front of proxy manual
1 parent f7c5487 commit 6dfcd12

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

readme.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,20 @@ Proxied: www.google-analytics.com/collect?v=1&_v=j73&a=531530768&t=pageview&_s=1
115115

116116
Check the [test-static/index.html](test-static/index.html) file's code to see how to bind the proxied analytics to your front end.
117117

118-
## Configuration
118+
### Proxy in Front of the Proxy
119+
120+
Before the request hits this NodeJS app / container, you have to proxy/assign some useful headers to it (`host` and `x-real-ip` or `x-forwarded-for`). Below is the example of the minimal Nginx proxy configuration.
121+
122+
```
123+
location /gtm-proxy/ {
124+
proxy_set_header Host $host;
125+
proxy_set_header x-real-ip $remote_addr;
126+
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
127+
proxy_pass http://app-address-running-in-your-infrastructure;
128+
}
129+
```
130+
131+
## Configuration
119132

120133
You can configure which third-parties to proxy/replace and how to do it in the config file. Find the actual configuration in [config.js](config.js) file:
121134

src/modules/proxy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function createDefaultProxy (targetDomain, proxyOptionsOverride = {}) {
8585
) {
8686

8787
const parsedUrl = url.parse(unmasked);
88-
const pverwrittenIp = req.headers["x-forwarded-for"] || req.headers["x-real-ip"];
88+
const pverwrittenIp = req.headers["x-forwarded-for"] || req.headers["x-real-ip"]; // TODO: || req.connection.remoteAddress; // in case no proxy is used (dedicated domain)
8989
const clientIp = pverwrittenIp
9090
? pverwrittenIp.split(/,\s?/g)[0]
9191
: req.connection.remoteAddress.split(":").pop();

0 commit comments

Comments
 (0)