GearHack

: : :

Add Comment | Related Links | TrackBack
Related Content

Preventing Your Web Server From Blocking Facebook Share

Today, I noticed that Facebook could not scrape any information from some of our web sites. In fact, when I tried to share articles on Facebook from these web sites, Facebook simply posts the URL without a title, a description, nor an image.

Funny thing, this problem only occurs on web sites running on two servers that we operate ourselves. Our web sites running on shared hosting servers do not have this problem. That points to a web server configuration issue.

Using the Facebook debugger tool on the problematic web sites, we get this error message: "Error Parsing URL: Error parsing input URL, no data was scraped."

Finally, we traced it down to the fact that Apache's default mod_security rule blocks all Facebook connection. This security rule watches a certain connection header that many spammers use and prevents connection. It turns out that Facebook also uses this header. It's not clear why Facebook uses this header, rather then using a more "legitimate" header. However, the solution is to add a mod_security rule to allow Facebook connection:

<IfModule mod_security.c>
SecRule SERVER_NAME "facebook\.com$" phase:1,nolog,allow,ctl:ruleEngine=off
</IfModule>

Simple add the above rule to your Apache web server configuration. In our Ubuntu installation, that's the "/etc/apache2/apache2.conf" file. After adding the mod_security rule, restart the Apache server. With this change, Facebook should have no problem getting a valid response from your server.

Mel
Wed, 22 Aug 2012 05:48:14 +0400

Looks like it's a little more difficult than what's been outlined so far. For example, if you put the URL of this page into the Facebook debugger, you will likely get the "Error Parsing URL: Error parsing input URL, no data was scraped." error message. However, if you use "http://www.GearHack.com/", then the debugger returns the results fine. Somehow, the root page differs from the sub-page.

What we are also noticing is that the Facebook debugger may parse the sub-page correctly three times. Then the third time, start to return the error message. It's not clear if Facebook debug tool is doing that or our web server is shutting down Facebook after the third attempt.

Mel
Thu, 23 Aug 2012 01:16:11 +0400

It turns out that mod_security problem identified above may be an issue for some servers, but isn't the problem in our case. Our server constantly returns 206 to Facebook. However, the two servers in question responds too slowly at times, causing Facebook to timeout. The slowness in response is caused by the "gethostbyaddr" PHP function call, where we convert the remote IP address to a domain name. It seems to respond fast enough on our two shared hosting server, but not faster enough on our dedicated server (go figure). Once we removed the call, Facebook debugger has no problem retrieving and parsing our web pages. We still do not have a solution to speed up the "gethostbyaddr" function.

Mel
Thu, 23 Aug 2012 02:43:58 +0400

I have this error "Error Parsing URL: Error parsing input URL, no data was scraped, when I tried it on facebook debugger.
Some news can be shared and other no. This is an example of news that I can not shared : http://turismodebolsillo.com.ar/noticias_ver.php?idnoticia=2 . . . Is the problem apache configuration?
Thanks.

Nora Costa

Nora Costa
Tue, 10 Mar 2015 03:47:54 +0300

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

TrackBack

TrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.

Send Ping | TrackBack URL | Spam Control

Title: Facebook Debug Tool Shows 403 Error
Weblog: GearHack
Excerpt: Well this is the fix if FB is showing 403 error. 1. Add OG: meta tags for title, description, image, type (google it like i did) 2. Probably the real reason why I got 403 is mod_sec rule false positive. Add this to your rules to ignore and that should fix it for you. SecRuleRemoveById 958291
Tracked: Tue, 19 Dec 2017 22:10:50 -0800

Add Comment

Spam Control | * indicates required field
Your Name: *
E-mail:
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(20 MB Max)
Spam Protection: * Answer of 8 + 3?
Click button only once, please!

Messages, files, and images copyright by respective owners.


Articles | Wiki
Forums | Latest | RSS
Library | Links | News
Search | Store | Help

176 Users Online

Hacking Digital Cameras
Fun for Photographers


Get Our

Memecoins!



Hacking Digital Cameras
Fun for Photographers

Amazon Associate

Copyright © 2004 - 2024. All Rights Reserved.