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 http://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 http://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"';
}
}