Mondoze Knowledge Base

Search our articles or browse by category below

Adding the CF-RAY header to your logs

Last modified: October 5, 2022
You are here:
Estimated reading time: < 1 min

How To Add CF-RAY Header To Your Logs

The CF-RAY header is added to help with tracing a request to a website through Cloudflare’s network. You can use the ID when working with Cloudflare Support to help troubleshoot any related issues you may have with connectivity. At the same time, you can reveal this “Ray ID” in your logs by making some edits to configuration files in Apache and Nginx. 

For Apache:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %{CF-Ray}i" cf_custom
CustomLog log/access_log cf_custom

For nginx:

log_format cf_custom '$remote_addr - $remote_user [$time_local]  '
                    '"$request" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent" '
                    '$http_cf_ray';

access_log  /var/log/nginx/access.log cf_custom;
Was this article helpful?
Dislike 0
Views: 1465