By running a full site cache or to simply keep track of visits to your CDN side, it is necessary to be able to pass the visitor's IP address back to the origin server where it can be utilized. This presents the question; how can we successfully pass the IP address to the origin if the CDN files are cached?
The EdgeRules feature is available only on Enterprise plans.
To perform this task, we must choose or create one small file that will never be cached, and use it as a carrier of the visitor's IP address.
Another question this presents; which header to use? Nginx servers support the X-Forwarded-For
header so all that is required is a two directive rule, and this can be setup as follows below.
Creating the Rule
Resulting Nginx Configuration Block
location ^~ /allpresent_file.css {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_no_cache 1;
...
}
Use-Case Variant
If the server configuration uses a custom setting or the old configuration with a previous CDN provider requires usage of a different header convention/name, the existing EdgeRule can still be used, but must be modified; renaming the X-Forwarded-For
header to the custom header, for example, User-IP
.
-
Resulting Nginx Configuration Block
location ^~ /allpresent_file.css { proxy_set_header User-IP $remote_addr; proxy_no_cache 1; ... }
We hope this article was helpful and as always, If there are any questions or concerns about any of the topics mentioned in this article, please feel free to reach out to support - we are available 24/7 by chat or email!