How to add HTTP response headers and DNS TXT records
If you are not experienced in adding or modifying HTTP headers or DNS records, we recommend that you familiarize yourself with this process before proceeding. To add HTTP response headers to your website, you need to adjust the configuration of your website. The way to do this depends on the type and version of the software running on your server. We've included some examples below to help you set it up.
HTTP response headers
Please keep in mind that if the header value contains double quotes (") you will need to escape them (\") to avoid breaking the configuration. Example:
"{\"report_to\":\"default\",\"max_age\":2592000,\"include_subdomains\":true}"
NGINX
In your server { } block add:
add_header HEADER_NAME "HEADER_VALUE" always;
Apache
Add the following to your httpd.conf in your VirtualHost or in an .htaccess file:
Header always set HEADER_NAME "HEADER_VALUE"
IIS
You can use the HTTP Response Headers GUI in IIS Manager or add the following to your web.config:
<system.webServer> <httpProtocol> <customHeaders> <add name="HEADER_NAME" value="HEADER_VALUE" /> </customHeaders> </httpProtocol> </system.webServer>
Vercel Now
Add the following to your now.json file at the root of your project. More information can be found here:
{ "headers": [ { "source": "/(.*)", "headers": [ { "key": "HEADER_NAME", "value": "HEADER_VALUE" }, ] } ] }
Lambda@Edge / Amazon CloudFront
Create a Lambda function and add the following code. Pay attention to the lower-case and mixed-case header keys in the included example. More information can be found here:
'use strict'; exports.handler = (event, context, callback) => { // Get contents of response const response = event.Records[0].cf.response; const headers = response.headers; // Set new header(s) // headers['HEADER_NAME'] = [{key: 'HEADER_NAME', value: "HEADER_VALUE"}]; headers['content-security-policy'] = [{key: 'Content-Security-Policy', value: "default-src 'none'; img-src 'self'"}]; // Return modified response callback(null, response); }
DNS TXT Records
BIND Server
If your domain is hosted by Bind DNS server, you can add DMARC record by locating your domain's zone file and opening it with your preferred editor, then add the following content:
; DMARC
_dmarc.yourdomain.com. IN TXT "v=DMARC1; p=none; rua=mailto:dmarc@example.uriports.com; ruf=mailto:dmarc@example.uriports.com"
Other
Most DNS services have a DNS Web administration where you can set up DNS records. Use the following values:
HOST: "_dmarc"
TYPE: TXT
VALUE:"v=DMARC1; p=none; rua=mailto:dmarc@example.uriports.com; ruf=mailto:dmarc@example.uriports.com".