Content-Security-Policy issues (NGINX)

TheUnnamed asked:

I am working with NGINX and I have a couple issues here.

I have a domain and one subdomain

Server block for domain

listen       80;
server_name  just4bettors.mobi  www.just4bettors.mobi;
root   /home/c0pt/capilleira/capilleiraclickandgamblemobile/www

Server block for subdomain

listen 80;
server_name www.desktop.just4bettors.mobi desktop.just4bettors.mobi;
root   /home/c0pt/capilleira/capilleiraclickandgambleweb/dist;

for the domain everything works properly, you can access to the page and log and there is nothing wrong, but once you try to enter to the subdomain, you can see an error on the screen Server not found when you enter http://www.desktop.just4bettors.mobi, and when you enter http://desktop.just4bettors.mobi you get GET http://desktop.just4bettors.mobi/ net::ERR_NAME_NOT_RESOLVED

Content-Security-Policy for domain

add_header Content-Security-Policy
  "default-src 'self';
  script-src 'self' 'unsafe-inline' 'unsafe-eval';
  style-src 'self' 'unsafe-inline' https://fonts.googleapis.com  https://themes.googleusercontent.com https://fonts.gstatic.com https://assets.zendesk.com;
  object-src 'none';
  connect-src http://just4bettors.mobi http://just4bettors.mobi:1337 http://www.just4bettors.mobi;";

now these are the Content-Security-Policy for the sub-domain

add_header Content-Security-Policy
  "default-src 'self';
  script-src 'self' 'unsafe-inline' 'unsafe-eval' http://www.just4bettors.mobi http://www.desktop.just4bettors.mobi;
  style-src 'self' 'unsafe-inline'
  object-src 'none';
  connect-src http://desktop.just4bettors.mobi http://www.desktop.just4bettors.mobi;";

so, what am I missing ? basically, the question would be: why I can not access to the subdomain ?

PD: all the DNS part is done already.

My answer:


You said that: “all the DNS part is done already.” In fact, all the DNS part is not done already. We can clearly see:

$ host just4bettors.mobi
just4bettors.mobi has address 190.171.28.156
$ host www.just4bettors.mobi
www.just4bettors.mobi has address 190.171.28.156
$ host desktop.just4bettors.mobi
Host desktop.just4bettors.mobi not found: 3(NXDOMAIN)
$ host www.desktop.just4bettors.mobi
Host www.desktop.just4bettors.mobi not found: 3(NXDOMAIN)

You just need to set up your DNS records correctly.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.