Daniel Hoelbling-Inzko talks about programming

The story of NginX, Facebook and ipv6

I just released my professional photography website to the public and was quite content with the setup. The site is running Wordpress on php5-fpm proxied through NginX. I optimized the hell out of the site using w3-total-cache, and the NginX + php5-fpm setup delivers superb performance.

Only Google and Facebook where giving me a hard time with site-verifications and other checks to see if tracking codes are correctly embedded. After digging a bit I noticed that the Facebook Linter was only seeing "Welcome to NginX" which is the default site set up on the server.

So I started taking apart my NginX configuration, testing different things and even though I could access the site correctly using Chrome, sometimes on other computers it would still show the default page. I was puzzled to say the least. Also Chrome makes it exceptionally hard to debug these problems due to being too smart. I had deliberately set up the site to only be available without www and was planning on configuring the 301 redirect, but somehow forgot to - turns out Google did it all by himself and never told me about it. So I was there thinking the site 301 redirects, but instead people with certain browsers ended up seeing the Nginx default page.

Once I realized that curl on my server was also only returning the default page it started to dawn on me. I had set up a AAAA record by default, and NginX was listening for ipv6 traffic, just the photography host was not configured to listen for it. So any requests that came in through ipv6 where hitting the default_server, not the actual host. Once I configured the listen [::]:80; ## listen for ipv6 line in my nginx host configuration everything started to work as expected and also Facebook started to see the page.

So lesson learned: Facebook tries ipv6 if possible, and if your server has a ipv6 DNS record but is not configured correctly, users will see your site (due to the browsers being smart), but crawlers may miss it. So always check v6 connectivity when launching a new site.

Filed under server, nginx, facebook, ipv6, network

My Photography business


dynamic css for .NET