header_filter_by_lua_block {
  if not string.find(ngx.req.get_headers()["Host"], "defaultdrop.net") then
    if not string.find(ngx.req.get_headers()["Host"], "talk.hatthieves.es") and not string.find(ngx.req.get_headers()["Host"], "metrics.hatthieves.es") and not string.find(ngx.req.get_headers()["Host"], "meet.hatthieves.es") then
      ngx.header["X-Frame-Options"] = "SAMEORIGIN";
    else
      ngx.header["X-Frame-Options"] = "ALLOWALL";      
    end
    if string.find(ngx.req.get_headers()["Host"], "social.hatthieves.es") then
      ngx.header["Content-Security-Policy"] = "default-src 'none' 'unsafe-inline' https://talk.hatthieves.es; base-uri 'self'; frame-ancestors 'none'; img-src 'self' data: https:; media-src 'self' https:; style-src 'self' 'unsafe-inline'; font-src 'self'; manifest-src 'self'; connect-src 'self' https://social.hatthieves.es wss://social.hatthieves.es https://talk.hatthieves.es wss://talk.hatthieves.es; script-src 'self' 'unsafe-inline' https://talk.hatthieves.es wss://talk.hatthieves.es; upgrade-insecure-requests;";
    end
    if string.find(ngx.req.get_headers()["Host"], "webmail.hatthieves.es") then
      ngx.header["Content-Security-Policy"] = "default-src 'none' 'unsafe-inline' https://metrics.hatthieves.es; base-uri 'self'; frame-ancestors 'none' https://metrics.hatthieves.es; img-src 'self' data: https:; media-src 'self' https:; style-src 'self' 'unsafe-inline'; font-src 'self'; manifest-src 'self'; connect-src 'self' https://social.hatthieves.es wss://social.hatthieves.es https://metrics.hatthieves.es; script-src 'self' 'unsafe-inline' https://metrics.hatthieves.es; upgrade-insecure-requests;";
    end
    ngx.header["Strict-Transport-Security"] = "max-age=31536000; includeSubDomains";
    ngx.header["X-Download-Options"] = "noopen";
    ngx.header["X-Content-Type-Options"] = "nosniff";
    ngx.header["Referrer-Policy"] = "same-origin";
    ngx.header["X-XSS-Protection"] = "1; mode=block";
    ngx.header["X-Permitted-Cross-Domain-Policies"] = "none";
  end
}
