Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To add Google ads.txt directly in nginx config, you can use the add_header directive in your server block to set the Content-Type and Content-Disposition headers for the ads.txt file. Here's an example configuration:

server {
  listen 80;
  server_name example.com;

  location /ads.txt {
    add_header Content-Type 'text/plain';
    add_header Content-Disposition 'inline; filename="ads.txt"';
    return 200 "google.com, pub-1234567890123456, DIRECT, f08c47fec0942fa0\n";
  }

  # your other server blocks and configurations go here
}

In this example, we define a location block for the ads.txt file, and set the Content-Type and Content-Disposition headers using the add_header directive. We also use the return directive to return the contents of the ads.txt file directly in the response.

Note that the contents of the ads.txt file should be replaced with your own Google Publisher ID and other relevant information. You can find more information about the contents of the ads.txt file on the official IAB website.