
Apache 設定でいくつかのタグを設定したいですLocation
。たとえば/image
、、、を に渡します/file
。現在、私は にこれを使用しています:/audio
localhost:port/path
/image
<Location /image>
RewriteEngine on
Options +MultiViews +FollowSymLinks
AllowOverride All
ProxyPreserveHost On
ProxyPass "http://localhost:PORT/image"
ProxyPassReverse "http://localhost:PORT/image"
</Location>
すべてのパラメータに対してこのコードを記述する必要がありますか? または、ショートカットはありますか?
ありがとう!
答え1
<Location /image> RewriteEngine on Options +MultiViews +FollowSymLinks AllowOverride All ProxyPreserveHost On ProxyPass "http://localhost:PORT/image" ProxyPassReverse "http://localhost:PORT/image" </Location>
すべてのパラメータに対してこのコードを記述する必要がありますか?
いいえ。RewriteEngine
ディレクティブはそこでは何も行いません。また、ローカル ファイル システム上のリソースにマップしない場合は、ディレクティブOptions
もディレクティブAllowOverride
も意味をなしません。これらのオプションは、ディレクティブを使用してリクエストを転送する「リモート」 Web サーバーによって制御され、設定する必要がありますProxyPass
。
これらのディレクティブは役に立たないので、それらを設定するためにロケーションブラケットも必要ありません。インラインを使用できます。ProxyPass
とにかく推奨される構文。
これにより、構文は必要な行のみに削減されます。
ProxyPreserveHost On
ProxyPass "/image" "http://localhost:PORT/image"
ProxyPassReverse "/image" "http://localhost:PORT/image"
ProxyPass "/file" "http://localhost:PORT/file"
ProxyPassReverse "/file" "http://localhost:PORT/file"
Apache httpdはInclude
ディレクティブを使用すると、同じ行を何度もコピーすることなく、さまざまな場所、VirtualHost、Location、Directory ブロックにそのまま含める設定を含む単一の構成スニペットを維持できます。