Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Link.php to support sites behind Cloudflare #2

Merged
merged 1 commit into from
Nov 4, 2016

Conversation

DeftNerd
Copy link
Contributor

@DeftNerd DeftNerd commented Nov 4, 2016

Sites behind Cloudflare can access the IP address of the visitor by looking for a HTTP_CF_CONNECTING_IP header.

Cloudflare does set the HTTP_X_FORWARDED_FOR header, but if the visitor is behind a Proxy themselves, it starts getting weird and hard to parse. The HTTP_CF_CONNECTING_IP header is the easiest way.

If there is an "X-Forwarded-For" header present in the request, CloudFlare will append the client's IP to its value, as the last in the list.

"X-Forwarded-For: A.B.C.D[,X.X.X.X,Y.Y.Y.Y,]"

where A.B.C.D is the client's IP address, also known as the original visitor IP address. X.X.X.X and Y.Y.Y.Y in this example are IP addresses along the route in the header value.

From https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-CloudFlare-handle-HTTP-Request-headers-

Sites behind Cloudflare can access the IP address of the visitor by looking for a HTTP_CF_CONNECTING_IP header. 

Cloudflare does set the HTTP_X_FORWARDED_FOR header, but if the visitor is behind a Proxy themselves, it starts getting weird and hard to parse. The HTTP_CF_CONNECTING_IP header is the easiest way. 

```
If there is an "X-Forwarded-For" header present in the request, CloudFlare will append the client's IP to its value, as the last in the list.

"X-Forwarded-For: A.B.C.D[,X.X.X.X,Y.Y.Y.Y,]"

where A.B.C.D is the client's IP address, also known as the original visitor IP address. X.X.X.X and Y.Y.Y.Y in this example are IP addresses along the route in the header value.
```

From https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-CloudFlare-handle-HTTP-Request-headers-
@ConsoleTVs
Copy link
Owner

Well done, lets add it!

@ConsoleTVs ConsoleTVs merged commit 7f4230a into ConsoleTVs:master Nov 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants