How to verify Bing SiteAuth with Nginx

Posted on  by 

With Bing Webmaster Tools you can view how well your site is performing in Bing search. Before you can start analysing your search statistics, you need to verify that you own the site you would like to analyse. If you are using Nginx to serve your sites content, you will learn in this tutorial how to verify your site by just adding a few lines in your Nginx configuration.

To verify a site in Nginx it is enough to add an additional location entry to your server configuration:

location /BingSiteAuth.xml {
        rewrite ^/(.*)  $1;
        return 200 "<users><user>{{YOUR_KEY}}</user></users>";

location / {
    // the default configuration goes here   

As you can see, we "intercept" the request for the HTML resource and immediately return a simpe 200 response with the XML content (which Bings site verification requires). You need to replace the part {{YOUR_KEY}} with your verification key. After adding this part to your Server configuration we just need to restart our Nginx server:

sudo systemctl restart nginx

From now on your site verification process should pass. If you have any questions or comments, let us know in the section below.