cdk-turnkey / sredirect

Send redirects for domain names over HTTPS.
Apache License 2.0
0 stars 0 forks source link

Redirect from a set of configurable sources #4

Open douglasnaphas opened 2 years ago

douglasnaphas commented 2 years ago

From https://advancedweb.hu/how-to-use-cloudfront-functions-to-change-the-origin-request-path/

function handler(event) {
    var request = event.request;
    request.uri = request.uri.replace(/^\/[^/]*\//, "/");
    return request;
}
douglasnaphas commented 2 years ago

CloudFront Functions event structure.

douglasnaphas commented 2 years ago

I can route based on the Host header. The CloudFront Functions event's request object has the headers. So I can have some-form.douglas-naphas.org route to a Google Form, and douglas-naphas.org route to a Google Site, using the same distro.

douglasnaphas commented 2 years ago

Testing

Before delegating DNS with the hosting provider, can I send, with CURL or fetch, a request to the distro (with its CloudFront domain name) where the HTTP Host header is the domain from a from-value?

douglasnaphas commented 2 years ago

I'd better consider the CloudFront Functions JavaScript runtime features.

douglasnaphas commented 2 years ago

For testing: https://daniel.haxx.se/blog/2018/04/05/curl-another-host.