dnscontrol icon indicating copy to clipboard operation
dnscontrol copied to clipboard

Generalize CF_REDIRECT for other providers

Open DrMurx opened this issue 5 years ago • 4 comments

I propose to deprecate/remove the CF_ prefix of CF_REDIRECT and CF_TEMP_REDIRECT to allow other providers implementing redirects.

While CloudFlare is currently the only provider for those redirect directives, making this a general directive would allow to create something like a nginx or apache provider which would generate configuration snippets for the respective webservers.

DrMurx avatar Mar 05 '19 16:03 DrMurx

Some providers support wildcards, others don't. Can you suggest a syntax that would work universally?

tlimoncelli avatar Nov 06 '20 16:11 tlimoncelli

Some providers support wildcards, others don't. Can you suggest a syntax that would work universally?

Why would that be an issue? It's REDIRECT(from, to) and if you use wildcards in from and the provider of choice doesn't support wildcards, you'll get an error. However, I'd only support a generic match-all wildcard *, not complex regex patterns.

DrMurx avatar Nov 06 '20 18:11 DrMurx

I see. Yes, the lowest common denominator would be REDIRECT(from, to). We'd have to add to the validator code any providers that don't permit wildcards.

Or, we could forbid wildcards since we want REDIRECT() to be fully generic.

tlimoncelli avatar Nov 12 '20 15:11 tlimoncelli

Proposal:

  • A generic HTTP redirect function called GENERIC_REDIRECT() that providers can opt into via Capabilities.
  • GENERIC_REDIRECT() provides a restricted set of features that can be expected on all providers that opt-in.
  • It should default to 302 (temporary), with a GENERIC_REDIRECT(from, to, OPT_PERMANENT) for 301 (Suggestions on a better name?)
  • Providers should implement a fully-featured redirect named ${PROVIDER}_${VERB} where $VERB reflects the feature as $PROVIDER names it. They should then implement GENERIC_REDIRECT() as a edifice to ${PROVIDER}_${VERB}
  • Wildcards are not supported. (We could add this in the future)

Thoughts?

I feel like REDIRECT() plus OPT_* for new features we add in the future is a good way to go. I also considered using different names instead of options (REDIRECT_301(), REDIRECT_302(), REDIRECT_WILDCARD(), etc.) but my hope is to create one redirect infrastructure that can be extended with OPT_ functions. We can use the AuditRecords() function to allow providers to reject/accept options.

tlimoncelli avatar Mar 11 '21 21:03 tlimoncelli

This is stale. I'm closing this. Please re-open if needed. Thanks!

tlimoncelli avatar Dec 14 '23 19:12 tlimoncelli