https://your_server/redmine/attachments/download/1234/日本語ファイル名.pdf などで問題が生じる。設定は次。

RewriteRule ^(/redmine.*) http://127.0.0.1:1234$1 [L,P,NE]
  か
ProxyPass /redmine/       http://127.0.0.1:1234/redmine/

Redmine まで伝わっていれば次のようになり

Internal error

An error occurred on the page you were trying to access.
If you continue to experience problems please contact your Redmine administrator for assistance.

If you are the Redmine administrator, check your log files for details about the error.

Back

rack止まり? thin止まり? だと次のようになる。

Bad request

ブラウザから https://your_server/app/日本語 として試行錯誤してみると

apache設定                                                           httpd-access.log
----------------------------------------------------------------------------------------------------------------
リクエスト自体                                                       GET /app/%E6%97%A5%E6%9C%AC%E8%AA%9E
RewriteRule ^(/app/.*)  http://127.0.0.1:1234$1 [L,P]                GET /app/\xe6%97%A5\xe6%9C%AC\xe8\xaa%9E
RewriteRule ^(/app/.*)  http://127.0.0.1:1234$1 [L,P,NE]             GET /app/\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e
RewriteRule ^(/app/.*)  http://127.0.0.1:1234${escape:$1} [L,P,NE]   GET /app/%e6%97%a5%e6%9c%ac%e8%aa%9e
ProxyPass /app/    http://127.0.0.1:1234/app/                        GET /app/\xe6%97%A5\xe6%9C%AC\xe8\xaa%9E

どうやら RewriteRule でマッチさせる文字列はデコード済みで
NE (noescape) 無しだと、エスケープするが (ap_escape_uri の挙動なのか)元々エスケープされていた範囲をエスケープしてくれる訳ではなさそうだ。
NE (noescape) 有りだと、Bad request となり Redmine まで伝わっていないようだ。

escape を使えばリクエストは通るのだが、エスケープ後が小文字になってしまっていて保存されていない。

RewriteMap escape int:escape
RewriteRule ^(/app/.*)  http://127.0.0.1:1234${escape:$1} [L,P,NE] # GET /app/%e6%97%a5%e6%9c%ac%e8%aa%9e

%{THE_REQUEST} を使えば保存されるが、こんな解しかないのだろうか。。。

RewriteCond %{THE_REQUEST}  "^\S+ (\S+)"
RewriteRule ^/app/.*   http://127.0.0.1:1234%1 [L,P,NE]            # GET /app/%E6%97%A5%E6%9C%AC%E8%AA%9E

過去の Redmine,rack,thin だと問題は生じていなかった気がするのだけれど。。。

コメントする

perl adv
perl adv