Caddy: Redirect when_unix greater_than/less_than

Created on 3 May 2019  路  3Comments  路  Source: caddyserver/caddy

1. What would you like to have changed?

Allow redirecting based on datetime placeholders like {when_unix}. The http.rewrite conditions currently do not allow something like greater_than or less_than for comparing integers.

2. Why is this feature a useful, necessary, and/or important addition to this project?

It would be very useful to allow specifying a date after which a redirect should occur, e.g. after a deprecation deadline.

3. What alternatives are there, or what are you doing in the meantime to work around the lack of this feature?

Manually editing the Caddyfile after the deadline to redirect users to the new address.

feature request

Most helpful comment

@SteffenDE Here's how to do it with the expression matcher (in v2.1)

@then expression `{time.now} > timestamp(1590106550)`

(The backticks aren't necessary in this case, but I like to enclose the expression in a single token for readability.)

You can also pass an RFC3339-formatted string into CEL's timestamp() function to make it a timestamp.

All 3 comments

This is really easy to add to Caddy 2. Interested in contributing it?

@SteffenDE Here's how to do it with the expression matcher (in v2.1)

@then expression `{time.now} > timestamp(1590106550)`

(The backticks aren't necessary in this case, but I like to enclose the expression in a single token for readability.)

You can also pass an RFC3339-formatted string into CEL's timestamp() function to make it a timestamp.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yu-chenxi picture yu-chenxi  路  3Comments

kilpatty picture kilpatty  路  3Comments

klaasel picture klaasel  路  3Comments

ericmdantas picture ericmdantas  路  3Comments

aeroxy picture aeroxy  路  3Comments