How to determine the HTTP Headers sent by a CDN
I wanted to detect if a request sent to my webserver is routed via a CDN or not. With Akamai we can add a setting to the akamai property to add a HTTP header to the request to determine this.
It's possible to look at the HTTP headers sent in the HTTP request using nginx. To log the HTTP request headers we enable debugging in the nginx logs:
Edit the following file:
/var/nginx/nginx.conf
To turn on debugging make the following change:
error_log /var/log/nginx/error.log debug;
Then restart the server:
sudo service nginx restart
Once this done, make a request which is routed via the CDN. From the logs:
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "Accept: image/png;q=1.0,image/jpeg;q=0.6,image/gif;q=0.4,image/*;q=0.2,*/*;q=0.1"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "X-Image-Server-TTL: 3"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "X-Aka-Imaging-Request: 1"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AkamaiImageServer VelocitudeMP/1.0;IM/1.0"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "X-Akamai-SR-Hop: 1"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "True-Client-IP: 23.46.175.14"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "Pragma: akamai-x-cache-remote-on"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "Pragma: akamai-x-get-request-id"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "Pragma: akamai-x-cache-remote-on"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "Pragma: akamai-x-get-request-id"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "Pragma: akamai-x-cache-remote-on"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "Pragma: akamai-x-get-request-id"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "X-Akamai-CONFIG-LOG-DETAIL: true"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "TE: chunked;q=1.0"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "Connection: TE"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "Accept-Encoding: gzip"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "Akamai-Origin-Hop: 2"
2023/09/22 02:00:15 [debug] 370030#370030: *1 http header: "Via: 1.1 c.v.image-server, 1.1 v1-akamaitech.net(ghost) (AkamaiGHost), 1.1 akamai.net(ghost) (AkamaiGHost)"