Fix %{HTTPS} / mod_rewrite compatibility for RPAFsethttps - #4
Merged
Conversation
Port the fix from gnif/mod_rpaf#6: mod_rewrite reads SSL state through the ssl_is_https optional function rather than the HTTPS environment variable, and it re-runs post_read_request, which dropped the HTTPS subprocess_env value on the second pass. * Store the HTTPS state in connection->notes ("rpaf_https") in addition to subprocess_env, and restore it early when the hook runs again so %{ENV:HTTPS} stays set across mod_rewrite's re-processing. * Register an ssl_is_https optional function (only when mod_ssl is not loaded) that reports the note, so RewriteCond %{HTTPS} works directly instead of requiring %{ENV:HTTPS}. * Unset the note in the request cleanup. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Port the fix from gnif/mod_rpaf#6: mod_rewrite reads SSL state through the ssl_is_https optional function rather than the HTTPS environment variable, and it re-runs post_read_request, which dropped the HTTPS subprocess_env value on the second pass.
Japanese following English
概要
RPAFsethttps Onで HTTPS を設定しても、mod_rewriteのRewriteCond %{HTTPS}が常にoffと判定される問題を修正します。gnif/mod_rpaf#6 で加えられた修正を取り込んだものです。問題
mod_rewriteは SSL の状態をHTTPS環境変数ではなくssl_is_httpsというオプション関数で判定します。そのため:%{ENV:HTTPS}は mod_rpaf が設定した値で正しく動く%{HTTPS}を直接使うと常にoffを返す加えて
mod_rewriteはpost_read_requestを再実行するため、2 回目の呼び出しでsubprocess_envのHTTPS値が失われていました。修正内容
subprocess_envに加えてconnection->notes(rpaf_https)にも保存し、フックが再実行された際に早期復元することで、mod_rewriteの再処理をまたいでも%{ENV:HTTPS}が維持されるようにしたmod_sslが未ロードの場合のみssl_is_httpsオプション関数を登録し、RewriteCond %{HTTPS}が%{ENV:HTTPS}を使わずに直接動くようにしたrpaf_httpsノートを削除テスト
CentOS 6 / Apache 2.2 のコンテナ上で、本修正込みのコードが正常にビルドされ、CI の機能テスト(#2 を再現: 許可IP→200 / 非許可IP→403)が通ることをローカルで確認済みです。
🤖 Generated with Claude Code