How To Enable Google Adsense ads.txt file for Drupal on Nginx

| Servers | 19 seen

Around early September 2019, in my Google AdSense dashboard, I noticed a warning informing me to create a separate ads.txt file. 

I followed the on-screen instruction and did what was asked.

After two months (at the start of November) I noticed my earnings from Google AdSense have dipped more than half and the warning was still there. 

Earnings at risk - You need to fix some ads.txt file issues to avoid severe impact to your revenue.

Authorized Digital Sellers, or ads.txt is an IAB initiative that helps ensure that your digital ad inventory is only sold through sellers (such as AdSense) who you've identified as authorized. Creating your own ads.txt file gives you more control over who's allowed to sell ads on your site and helps prevent counterfeit inventory from being presented to advertisers.

We strongly recommend that you use an ads.txt file. It can help buyers identify counterfeit inventory and help you receive more advertiser spend that might have otherwise gone toward that counterfeit inventory.

I decided to check and huge was my surprise when trying to visit ads.txt file I got the following warning:

403 forbidden ads.txt file

403 forbidden ads.txt file

To solve it I changed the server file and added the following lines

location = /ads.txt {
allow all;
log_not_found off;
access_log off;

Problem solved