Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open-uriが見る環境変数の追加 #484

Closed
sho-h opened this issue Aug 9, 2017 · 1 comment
Closed

open-uriが見る環境変数の追加 #484

sho-h opened this issue Aug 9, 2017 · 1 comment
Assignees

Comments

@sho-h
Copy link
Member

sho-h commented Aug 9, 2017

以下ではno_proxyがありませんが、

たぶん以下のfind_proxyまで降りてno_proxyが設定できる気がするので確認して追加する。

@sho-h sho-h self-assigned this Aug 9, 2017
@sada
Copy link
Contributor

sada commented Dec 16, 2023

こちらのissueの確認をしました。
Ruby 3.2.2の open-uri のデフォルトで no_proxy 環境変数が有効になっていました。

以下は確認した内容です。

Webrickのプロキシサーバを立ち上げておき、そのプロキシに対して open-urino_proxy 環境変数の指定によってプロキシ経由でアクセスする/しないを確認しました。

Webrickのプロキシサーバのコード。

require "webrick"
require "webrick/httpproxy"

 s = WEBrick::HTTPProxyServer.new(Port: 8080)
 Signal.trap('INT') do
   s.shutdown
 end
 s.start

Webrickのプロキシサーバを実行した時のログ。

$ ruby proxy.rb
[2023-12-16 15:14:19] INFO  WEBrick 1.8.1
[2023-12-16 15:14:19] INFO  ruby 3.2.2 (2023-03-30) [x86_64-linux]
[2023-12-16 15:14:19] INFO  WEBrick::HTTPProxyServer#start: pid=28219 port=8080
127.0.0.1 - - [16/Dec/2023:15:15:05 JST] "CONNECT 2023.rubyworld-conf.org:443 HTTP/1.1" 200 0
- -> 2023.rubyworld-conf.org:443

open-uri のコード。

require 'open-uri'

ENV['https_proxy'] = "http://localhost:8080"
ENV['no_proxy'] = "www.ruby-lang.org"

# no_proxy環境変数で設定したホスト名でプロキシを経由しない
URI.open("https://www.ruby-lang.org/en/") {|f|
  f.each_line { |l| puts(l) }
}
# localhost:8080 で立ち上げたプロキシを経由する
URI.open("https://2023.rubyworld-conf.org/ja/") {|f|
  f.each_line { |l| puts(l) }
}

open-uri の該当位置の説明に no_proxy 環境変数を追加します。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants