server {
    listen 443 ssl;
    server_name sfchat.dev;
    charset utf-8;

    gzip  on;

    ssl_certificate /etc/nginx/ssl/sfchat.crt;
    ssl_certificate_key /etc/nginx/ssl/sfchat.key;

    client_body_timeout 90s;
    client_header_timeout 90s;

    location ~ ^/static/([^\/]+)\.js$ {
        alias /sfchat/sfchat/static/js/app/$1.js;
    }

    location /static {
        alias /sfchat/sfchat/static;
    }

    location /requirejs-config.js {
        alias /sfchat/sfchat/static/js/app/requirejs-config.js;
    }

    location /chat/requirejs-config.js {
        alias /sfchat/sfchat/static/js/app/requirejs-config.js;
    }

    location / {
        proxy_ssl_verify off;

        proxy_pass https://sfchat-web:8001;
        proxy_set_header Host $host:8$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        add_header Content-Security-Policy "default-src 'self' script-src 'self' 'nonce-2726c7f26c' www.google-analytics.com data:; object-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self' www.google-analytics.com data:; media-src 'none'; child-src 'none'; font-src 'none'; connect-src 'self' www.google-analytics.com; report-uri //$host:8$server_port/csp-report/;";
        add_header X-Content-Security-Policy "default-src 'self'; script-src 'self' 'nonce-2726c7f26c' www.google-analytics.com data:; object-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self' www.google-analytics.com data:; media-src 'none'; child-src 'none'; font-src 'none'; connect-src 'self' www.google-analytics.com; report-uri //$host:8$server_port/csp-report/;";
        add_header X-WebKit-CSP "default-src 'self'; script-src 'self' 'nonce-2726c7f26c' www.google-analytics.com data:; object-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self' www.google-analytics.com data:; media-src 'none'; child-src 'none'; font-src 'none'; connect-src 'self' www.google-analytics.com; report-uri //$host:8$server_port/csp-report/;";
    }
}

server {
    listen 444 ssl;
    server_name sfchat.dev;
    charset utf-8;

    gzip  on;

    ssl_certificate /etc/nginx/ssl/sfchat.crt;
    ssl_certificate_key /etc/nginx/ssl/sfchat.key;

    location ~ ^/static/js/app/([^\/]+)\.js$ {
        alias /sfchat/sfchat/static/js/build/$1.js;
    }

    location /static {
        alias /sfchat/sfchat/static;
    }

    location /requirejs-config.js {
        alias /sfchat/sfchat/static/js/build/requirejs-config.js;
    }

    location /chat/requirejs-config.js {
        alias /sfchat/sfchat/static/js/build/requirejs-config.js;
    }

    location / {
        proxy_ssl_verify off;

        proxy_pass https://sfchat-web:8001;
        proxy_set_header Host $host:8$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        add_header Content-Security-Policy "default-src 'self' script-src 'self' 'nonce-2726c7f26c' www.google-analytics.com data:; object-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self' www.google-analytics.com data:; media-src 'none'; child-src 'none'; font-src 'none'; connect-src 'self' www.google-analytics.com; report-uri //$host:8$server_port/csp-report/;";
        add_header X-Content-Security-Policy "default-src 'self'; script-src 'self' 'nonce-2726c7f26c' www.google-analytics.com data:; object-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self' www.google-analytics.com data:; media-src 'none'; child-src 'none'; font-src 'none'; connect-src 'self' www.google-analytics.com; report-uri //$host:8$server_port/csp-report/;";
        add_header X-WebKit-CSP "default-src 'self'; script-src 'self' 'nonce-2726c7f26c' www.google-analytics.com data:; object-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self' www.google-analytics.com data:; media-src 'none'; child-src 'none'; font-src 'none'; connect-src 'self' www.google-analytics.com; report-uri //$host:8$server_port/csp-report/;";
    }
}
