Mobile app version of vmapp.org
Login or Join
Ann8826881

: AdSense ads not showing up after switching HTTP server to gunicorn + proxied nginx I am developing a webpage in Django in which contains two blocks of advertisements from Google AdSense. Before,

@Ann8826881

Posted in: #Django #GoogleAdsense #Nginx

I am developing a webpage in Django in which contains two blocks of advertisements from Google AdSense. Before, I was serving this page using Apache2, but I switched to gunicorn + nginx due to it's extreme simplicity to configure and deploy the application.

Although the whole page works fine, for some reason now the ads are not showing up anymore. Thinking that the server switch may be the cause sounds a little bit without sense for me, as the AdSense code is a JavaScript loaded by the client, not by the server, but the server switch was the only change made in the page before they stopped to work.

nginx serves the page's static files directly at /static/, while the Django WSGI application is served by gunicorn, but binded to localhost port 8001, and then redirected by nginx to /.

The website is live at 146.148.37.213/, if anyone is interested in checking the source code.

Here's my nginx site configuration:

server {
server_name 146.148.37.213;
access_log off;

location /static/ {
alias /var/www/Skorpius/static/;
}

location / {
proxy_pass 127.0.0.1:8001; proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}

}

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Ann8826881

1 Comments

Sorted by latest first Latest Oldest Best

 

@LarsenBagley505

The only way I the server change affects adsense is speed. If you switched to a server that performs slower than the last one, then you'll likely earn less or see irrelevant ads at best.

I couldn't use many of the various testing tools on your site because your URL is an IP address. Your first step is to change that IP address to an actual domain name so that google has something decent to list.

I tested your site both with firefox 15 and opera 11.6 web browsers, and when I loaded it in opera, a sidebar with terra servers or something appeared for a couple seconds then it disappeared. That can scare advertisers away because they will believe you're more interested in shifting their advertisements.

Luckily, I could test your page via webpagetest.org and your page loads differently for them, which perhaps is the way you wanted your page to load?

Also, you need to work on caching static content like external javascript pages, and compress images. See:
www.webpagetest.org/result/150324_D1_12BY/1/performance_optimization

Just remember, google runs with multiple IP addresses and could check your site from any of them. You want to deliver the correct page to everyone. and as for the source code, you might want to clean up the spaces and make it more compact and ditch the comment tags so that people on slow connections don't have to waste time downloading comments that they don't normally see.

Google also has similar results after tests. See:
developers.google.com/speed/pagespeed/insights/?url=146.148.37.213%2F

Google would pay you better if you try to make your site more mobile friendly as well.

And finally, condense the number of calls to external resources, especially if they're located on your server. For example, try to merge all javascript files to just one and use that.

As you can see, you have a lot of work to do in order to get some kind of quality ad on your website. Also, make sure you're not copying anyone else's content, and follow all recommendations by google and especially adsense policies.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme