LoginSignup
3
2

More than 5 years have passed since last update.

Nginx(HTTPS)でSubversion(HTTP/Apache)をリバースプロキシする場合に日本語ファイル名のmoveが失敗するとしたら 【Nginxの2重URLエンコーディング】

Last updated at Posted at 2017-09-06

NginxでHTTPSを終端させて、裏のSubversionにリバースプロキシしていた時、一見うまくいったように見えたけど、日本語ファイル名をsvn moveしたら失敗していたのをFixしたのでメモ。

TL;DR

タイトルのケースの場合、 Apacheに渡される Destination ヘッダが https:// で始まってしまうのを http:// で始まるように修正すれば直ると言われていますが、それをするはずの巷の $fixed_destination 対処$1 部分がURLエンコードされていようが、Nginxが更にURLエンコードしてしまう問題(%XX => %25XX)が出る可能性があります。(nginx:1.13.3 で確認済)

エンコードされていない $1 は、 <?var> 形式の名前付きキャプチャ機能を使えば取得することができます。

set $fixed_destination $http_destination;

if ( $fixed_destination ~ ^https(?<myurl>.*)$ ) {
    set $fixed_destination "http$myurl";
}
proxy_set_header Destination $fixed_destination;

上記を使えば日本語ファイル名の移動でも問題になりません。

英語のファイル名の場合はURLエンコードされずにURL上で表現可能なので、もともと問題が顕在化しません。

3
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2