yamashiro0110の日記

yamashiro0110の日記です。おもにIT技術のメモを綴っていきます(^o^)

Apache ProxyPassMatchの設定

Apache ProxyPassMatchの設定


正規表現にマッチしたURLに対してProxyする設定


環境

  • IPとPort:192.168.0.11:8888
  • Apache/2.2.26
  • DocumentRoot:/web/WebContent
  • /web/WebContent(DocumentRoot)以下のディレクトリ構成
html/test1
├── test1.html
├── test2.html
└── test3.html
html/test2
├── test1.html
├── test2.html
└── test3.html

ファイルの内容は下記の通り

  • test1/test1.html
test1-1
  • test1/test2.html
test1-2
  • test1/test3.html
test1-3
  • test2/test1.html
test2-1
  • test2/test2.html
test2-2
  • test2/test3.html
test2-3

例1

"test1"以下のtest0.html~test9.htmlにマッチするURLは、
"test2"以下のtest0.html~test9.htmlにproxyする

test1/test1.htmlの場合、test2/test1.htmlにproxyするという意味

    <IfModule proxy_module>
        ProxyPassMatch ^/html/test1/test([0-9]{1})\.html http://192.168.0.11:8888//html/test2/test$1.html
    </IfModule>

例2

設定に引数を渡さないように記載した場合

    <IfModule proxy_module>
        ProxyPassMatch ^/html/test1/test([0-9]{1})\.html http://192.168.0.11:8888//html/test2/test1.html
    </IfModule>