Category: snippets

Ignore herokuapp.com domain in nginx

I was having some trouble with duplicate content from my blog ericcarmichael.com being replicated on ericcarmichael.herokuapp.com.

I added this little bit to my Pelican buildout fork and now requests to myapp.herokuapp.com domain are denied by nginx!

http {
    server {
        listen <%= ENV["PORT"] %> default;
        rewrite ^ $scheme://myapp.com$request_uri? permanent;
    }

    server {
        listen <%= ENV["PORT"] %>;

        server_name myapp.com www.myapp.com;
    }
}

The first server block catches all and denies them, the second only accepts requests from where we want! Yay!

— 23 April 2014
…discuss this