MTA-STS worker example serving policy data directly

This example worker serves MTA-STS policy data directly. Adapt the reply variable to your needs and add this worker to each domain as a custom subdomain mta-sts.<your_domain>. This is a companion to -> https://github.com/fry69/certbot-cloudflare-dns-updaters
export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);
const path = url.pathname;

// Define the allowed paths
const allowedPaths = ['/.well-known/mta-sts.txt'];

// Check if the path is allowed
if (allowedPaths.includes(path)) {
let reply = 'version: STSv1\n';
reply += 'mode: enforce\n';
reply += 'mx: mx1.example.com\n';
reply += 'mx: mx2.example.com\n';
reply += 'max_age: 604800\n';
return new Response(reply, {
headers: {
"content-type": "text/plain",
},
});
} else {
// Serve a 404 response
return new Response('Not Found', { status: 404 });
}
},
};
export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);
const path = url.pathname;

// Define the allowed paths
const allowedPaths = ['/.well-known/mta-sts.txt'];

// Check if the path is allowed
if (allowedPaths.includes(path)) {
let reply = 'version: STSv1\n';
reply += 'mode: enforce\n';
reply += 'mx: mx1.example.com\n';
reply += 'mx: mx2.example.com\n';
reply += 'max_age: 604800\n';
return new Response(reply, {
headers: {
"content-type": "text/plain",
},
});
} else {
// Serve a 404 response
return new Response('Not Found', { status: 404 });
}
},
};
GitHub
GitHub - fry69/certbot-cloudflare-dns-updaters: Automates the proce...
Automates the process of creating and updating DANE TLSA and MTA-STS records in Cloudflare DNS - fry69/certbot-cloudflare-dns-updaters
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server