Add an ads.txt file at the root of a self-hosted Ghost blog (Nginx)

On a self-hosted ghost blog, you'll soon notice that there is no "public folder" where you can pour your ads.txt file and be good to go. Ewwww, bummer.

You can simply add this in your blog's nginx config file located in the /etc/nginx/sites-available/ folder :

location /ads.txt {
    alias /home/www-data/ads.txt;
}

(before the location / {... block, and don't forget to change the alias path to where you put your file)

then nginx -t to check if you messed up the config file

then sudo service nginx reload for the change to be applied !

IMPORTANT NOTE : If you already tried to access the ads.txt file url before, ghost will probably have redirected you to the "trailing slash" url equivalent and the browser will keep redirecting you there even after you changed nginx config. I personnaly just opened an ingognito window in chrome (CTRL+SHIFT+N) then I reloaded the url with CTRL+SHIFT+R and it got rid of the redirection.

The warning message in AdSense should disapear in the following 24h.

Hope it helps !