Skip to content

header_rewrite: Add set-plugin-cntl #12125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

maskit
Copy link
Member

@maskit maskit commented Mar 24, 2025

I was surprised that %{NOW} in header rewrite rules does not always use GMT.

cond %{NOW:<part>} <operand>
This is the current time, in the local timezone as set on the machine,
typically GMT. Without any further qualifiers, this is the time in seconds
since EPOCH aka Unix time. Qualifiers can be used to give various other
values, such as year, month etc.

The new operator, set-plugin-cntl, enables users to change fundamental behavior of header_rewrite plugin. I added TIMEZONE controller for now. You can use it like below to use GMT regardless of system setting.

cond %{SEND_RESPONSE_HDR_HOOK}
  set-plugin-cntl TIMEZONE GMT
  set-header hour %{NOW:HOUR}

I made this new operator applicable for other things because there's at least one more thing I want to change.

@maskit maskit added the header_rewrite header_rewrite plugin label Mar 24, 2025
@maskit maskit added this to the 10.2.0 milestone Mar 24, 2025
@maskit maskit requested a review from zwoop March 24, 2025 21:22
@maskit maskit self-assigned this Mar 24, 2025
@bryancall bryancall self-requested a review March 24, 2025 22:06
@maskit
Copy link
Member Author

maskit commented Mar 24, 2025

tls_conn_timeout failed

@maskit
Copy link
Member Author

maskit commented Mar 24, 2025

[approve ci autest 0]

================== ===================== =============================================================================================
Controller Operators/Conditions Description
================== ===================== =============================================================================================
TIMEZONE ``NOW`` If ``GMT`` is passed, the operators and conditions use GMT regardles of the timezone setting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOW is not a valid timezone, maybe put LOCAL there instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOW is not a default value. There are three columns and the second column shows the operators and conditions that are controlled by a controller.

const std::string &name = p.get_arg();
const std::string &value = p.get_value();

if (name == "TIMEZONE") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOCAL and GMT look like the only two possible values, should add that to the docs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already written on the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
header_rewrite header_rewrite plugin New Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants