0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PACのshExpMatchでハマった話

Last updated at Posted at 2025-01-31

プロキシー自動設定ファイル(Proxy Auto-Configuration, PAC)におけるshExpMatch関数でurl引数のパス部分をチェックし、一致したらプロキシを経由するように返すFindProxyForURL関数を作成したが、どうにも思い通りに動かない事態にハマった。

proxy.pacの例
function FindProxyForURL(url, host)
{
  if (shExpMatch(url, '*/check-path/*')) {
    return 'PROXY proxyhost:3128'
  }
  return 'DIRECT'
}

Chrome(バージョン: 132)でプロキシを経由しないとアクセス不可なURL(例:https://host/check-path/subpath/) にアクセスすると、直接(DIRECT)アクセスしているようで、ブラウザにはForbiddenと表示されてしまう。

原因

前述の問題の原因は、以下に記載されている通り、ブラウザのバージョンにより、スキームがhttps://のurl引数からパスとクエリーの部分をブラウザが削除するからだった。

回避策

ブラウザのバージョンにより、回避しようがないので諦めるしかない。

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?