I added the lines to my global.inc file for Aegir but got this:
Notice: Undefined index: HTTP_CF_CONNECTING_IP in /var/aegir/config/includes/global.inc on line 155
I am running aegir
cloudflare dns -> Aegir server -> aegir serves the website I specified on cloudflare virtually.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | cloudflare-n1138300-23.patch | 390 bytes | damienmckenna |
| #22 | menu_token-n1916532.patch | 1.37 KB | damienmckenna |
| #21 | cloudflare-notice-1138300.patch | 509 bytes | domidc |
Comments
Comment #1
Brian294 commentedThis is a single line, not multiple lines:
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"] ? $_SERVER["HTTP_CF_CONNECTING_IP"] : $_SERVER["REMOTE_ADDR"];
Comment #2
socialnicheguru commentedI know. I placed it but still get the error.
I am wondering if this is a variable that I need to set somewhere?
Comment #3
Brian294 commentedYou are getting this because the _SERVER variable is not set. What sort of server software configuration do you have?
Comment #4
socialnicheguru commentedVPS - linode.com
apache2
pressflow install
php v 5.2
$thishost = $_SERVER['HTTP_HOST']; <- works
# $thishost = $_SERVER['SERVER_NAME'] ; <-- doesn't work.
any help or pointers you can give me on howto best define these variables would be helpful.
Comment #5
Brian294 commentedPressflow has a Varnish configuration, yes? That might be part of the problem. Can you remove Varnish from the equation?
Comment #6
socialnicheguru commentedDont' have varnish enabled or installed.
Comment #7
Brian294 commentedmodify your php.ini so the error_reporting variable has the following:
error_reporting = E_ALL & ~E_NOTICE
You are probably set to STRICT which is causing those annoying notices. It's not an error in the code per-se, it's just PHP being picky about variables. STRICT is helpful while debugging code, but E_ALL & ~E_NOTICE is more appropriate for production environments.
Comment #8
socialnicheguru commentedwas actually just set to E_ALL
in addition to the HTTP_CF_CONNECTING_IP, SERVER_NAME is not defined.
Can you point me to where I might be able to set these variables for my system? Trying to google on set 'HTTP_CF_CONNECTING_IP' got me nowhere.
Comment #9
manfer commentedHTTP_CF_CONNECTING_IP is a HTTP header that cloudflare sets. It contains the value of the remote user address. It is not something you have to set yourself. Are you sure you have cloudflare correctly on for your site in cloudflare?
This module is just to make drupal work fine with cloudflare CDN but the domain must be configured to work with cloudflare in http://www.cloudflare.com/
I know maybe it is stupid to point that but it is better to be sure the domain is configured in cloudflare site. The notice indicates the header HTTP_CF_CONNECTING_IP is not in $_SERVER array.
And anyway that is a notice, if cloudflare is not configured the header will not be present and the value of $_SERVER['REMOTE_ADDR'] will not be changed.
Comment #10
Brian294 commentedAnietie,
Have you had an opportunity to implement this fix?
error_reporting = E_ALL & ~E_NOTICE
This will retain E_ALL, minus the annoying notices you are experiencing.
Let me know..
Peace,
Brian
Comment #11
socialnicheguru commentedI will try in the next few days.
I have a customer project to finish.
Comment #12
Brian294 commentedAnietie,
Have you had an opportunity to implement this fix?
error_reporting = E_ALL & ~E_NOTICE
Peace,
Brian
Comment #13
Brian294 commentedTry this snippet for settings.php instead. I may modify my install documentation if it works:
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; }Comment #14
mobonobomo commentedBrian, confirming that your snippet does work. I only noticed the "Index undefined" message when on the direct, CloudFlare-bypass CNAME of my site (since the variable wasn't being passed). Did not see the message on the CloudFlare enabled @ and www versions of the site.
Comment #15
alfthecat commentedHi Brian,
I'm getting the same error, also in an Aegir environment pretty identical I think as the OP.
I don't get the error on D6 websites. I do get them on D7 sites.
In my setup, I ask Aegir to add the cloudflare lines to every website it hosts. Aegir uses includes to basically compile a settings.php for the websites it hosts. Therefore, one can have global settings to be applied to all sites, and still have individual entries for individual sites as well.
The error looks like this for my D7 sites: Notice: Undefined index: HTTP_CF_CONNECTING_IP in include_once() (line 2 of /var/aegir/config/includes/global.inc).
Before I try #13 I just wanted to ask if this info prompts a different thought from your side. If not, can I just delete my old line and paste in if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; } instead?
Hope this helps and thanks in advance for any guidance!
Comment #16
alfthecat commentedOK, by major coincidence I might have solved this one....
On D6 websites, in Aegir, when I host a site on a temporary domain that is NOT configured in cloudflare (or as a subdomain of a cloudflare powered website) drupal does not print an error.
But, in D7 it does print an error if the site is on a domain that cloudflare is not aware of. Just now, a domain resolved through CF to a D7 site in my Aegir system... Error is gone.
@SocialNicheGuru could this be your issue as well?
Comment #17
socialnicheguru commentedSince I first posted this over a year ago, I had to remove this module as I had a client deadline so I can't comment on it.
Comment #18
alfthecat commentedOK, well... perhaps the issue can be marked as fixed? Since it can be reproduced by creating a D7 site in Aegir without adding it to CF, and then solved by... adding the site's domain to CF.
What do you think Brian? The only remaining issue I can think of is that maybe subdomains would still print the error, but if you add the subdomain to CF too, that should no longer be a problem either.
Comment #19
pedrospThe #13 snippet
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; }
removed correctly the message for me on 7.x-1.0-beta2
Comment #20
vulfox commentedI got this error when using it on a dreamhost basic shitty server. But I had not installed cloudflare through Dreamhost panel but I had to do it manually so that I could get rid of www in my domains (Dreamhost forces them when you install through their service).
Snippet #13 Placed in settings.php seem to get rid of the error message at least.
But how do I test if this is working and not just hiding the error message?
Comment #21
domidc commentedIf you get the notice it means the webserver is not receiving the HTTP_CF_CONNECTING_IP value. You can test this easly by setting the website in bypass mode. The notice will appear if you enable it, it appears.
The patch should resolve the issue.
Comment #22
damienmckennaThe patch from #21 needed some work, this version simplifies the code as follows:
Comment #23
damienmckennaThis version of the patch includes comments to indicate the start and end of the parts that need to be added to the settings file.
Comment #24
bunthorne commentedI just installed CloudFlare through my Arvixe host for my Drupal 7 site; following the installation instructions on the project page, I got the error for the HTTP_CF_CONNECTING_IP index. I had to replace the settings.php snippet with #13, and the error went away.
This issue was last updated in February, 6 months ago; it is marked for 6.x. Can it be resolved now? Does the project page need to be updated? Does the code need to be patched? (I'm "just" a site builder, sorry if I can't be more help.)
Comment #25
bryancasler commentedSince I was having similar problems, I'm giving this a try on the 7.x branch as well.
Comment #26
Brian294 commentedI have updated the documentation on the project page with the snippet of code provided by DamienMcKenna. Thank you.
Comment #27
Brian294 commentedComment #28
Mario Baron commentedI am getting all these notices after enabling cloudflare module
Comment #29
damienmckennaMario: Please open a new issue for these errors.