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?

Proxyサーバー設定備忘録

Posted at

Proxyサーバーの設定周りの色々

PACスクリプトで設定された色々

実際に使っているproxyサーバーを確認したい

Proxy設定用にPACスクリプトを指定している場合、接続先に応じてどのproxyを使っているかわからない。
特定のアクセス先(googleを例にする)に使っているproxyサーバーを調べるにはpowershellで以下のコマンドを実行する

$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
$uri   = [Uri]"https://www.google.com/"
$use   = $proxy.GetProxy($uri)

if ($proxy.IsBypassed($uri)) {
  Write-Output "DIRECT (プロキシ未使用)"
} else {
  Write-Output "PROXY: $($use.AbsoluteUri)"
}

返り値で、PROXY: http://proxy.example.jp:8080のように使われたproxyサーバーがわかる。

proxyサーバーの設定をしたい

WinINET、WinHTTPに依存したアプリケーション以外はPCAスクリプトの内容は一般に効かないので、powershellでproxy設定をして、コマンドラインでアプリケーションを起動することで、proxyサーバーを反映させることができる。

proxyサーバー設定用のコマンドは以下の通り。

$Env:HTTPS_PROXY = "http://proxy.example.jp:8080"

設定が反映されたかどうか知りたい場合は

echo $Env:HTTPS_PROXY

このproxy設定を活かしてアプリケーションを立ち上げたい場合は

Start-Process "C:\Path\To\App.exe"

で立ち上げられる。

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?