Server Gigabit Guide

Adding the CF-RAY header to your logs

You are here:
Estimated reading time: < 1 min

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 1
Views: 95