如何从代理 (ISA-NTLM) 后面更新 Ruby Gems
我后面的防火墙正在仅 NTLM 模式下运行 Microsoft ISA 服务器。 是否有人成功通过 Ruby SSPI gem 或其他方法安装/更新了 Ruby gem?
……或者我只是懒惰?
注意:rubysspi-1.2.4 不起作用。
这也适用于“igem”,IronRuby 项目的一部分
The firewall I'm behind is running Microsoft ISA server in NTLM-only mode. Hash anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method?
... or am I just being lazy?
Note: rubysspi-1.2.4 does not work.
This also works for "igem", part of the IronRuby project
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(20)
与其编辑批处理文件(您可能必须对其他 Ruby gem 执行此操作,例如 Bundler),最好只执行一次并正确执行此操作。
在 Windows 上,在我的公司代理后面,我所要做的就是将
HTTP_PROXY
环境变量添加到我的系统中。HTTP_PROXY
”的新系统变量,并将值设置为您的代理服务器根据您的身份验证要求,
HTTP_PROXY
值可以像以下一样简单:或更复杂,如其他人指出的那样
Rather than editing batch files (which you may have to do for other Ruby gems, e.g. Bundler), it's probably better to do this once, and do it properly.
On Windows, behind my corporate proxy, all I had to do was add the
HTTP_PROXY
environment variable to my system.HTTP_PROXY
", and set the Value to your proxy serverDepending on your authentication requirements, the
HTTP_PROXY
value can be as simple as:Or more complex as others have pointed out
如果使用代理,您可以导航至 Ruby downloads,单击“下载”,这将下载指定的update (或 Gem )到所需的位置。
接下来,通过 Ruby 命令行,使用以下命令导航到下载位置:
pushd [directory]
例如:
pushd D:\Setups
然后运行以下命令:
gem安装[更新名称] --local
例如:
gem install rubygems-update --local
。在 Windows 7 上使用 Ruby 更新版本 2.4.1 进行测试。
要检查,请使用以下命令:
ruby -v
If behind a proxy, you can navigate to Ruby downloads, click on Download, which will download the specified update ( or Gem ) to a desired location.
Next, via Ruby command line, navigate to the downloaded location by using :
pushd [directory]
eg :
pushd D:\Setups
then run the following command:
gem install [update name] --local
eg:
gem install rubygems-update --local
.Tested on Windows 7 with Ruby update version 2.4.1.
To check use following command :
ruby -v
对于任何使用 SSH 建立隧道的人; 您可以创建使用 SOCKS 代理的
gem
命令版本:gem installocksify
安装socksify
(您需要能够至少在没有代理的情况下执行此步骤)复制现有的 gem exe
在您最喜欢的编辑器中打开它,并将其添加到顶部(在 shebang 之后)
设置您的隧道
使用 proxy_gem 运行 gem 命令
for anyone tunnelling with SSH; you can create a version of the
gem
command that uses SOCKS proxy:socksify
withgem install socksify
(you'll need to be able to do this step without proxy, at least)Copy your existing gem exe
Open it in your favourite editor and add this at the top (after the shebang)
Set up your tunnel
Run your gem command with proxy_gem
我尝试了上述所有解决方案,但没有一个有效。 如果您使用的是 Linux/macOS,我强烈建议您通过 ssh 隧道使用 tsocks。 为了让这个设置工作,你需要一台可以通过 ssh 登录的机器,此外还需要安装一个名为 tsocks 的程序。
这里的想法是通过 SSH(socks5 代理)创建动态隧道。 然后,我们配置 tsocks 以使用此隧道并启动我们的应用程序,在本例中:
或考虑 Rails 3.0:
更详细的指南可以在以下位置找到:
http://blog.byscripts.info/2011/04/bypass-a-proxy-with-ssh-tunnel -and-tsocks-under-ubuntu/
尽管是为 Ubuntu 编写的,但该过程应该适用于所有基于 Unix 的计算机。 Windows 上 tsocks 的替代方案是 FreeCap (http://www.freecap.ru/eng/)。 Windows 上可行的 SSH 客户端称为 putty。
I tried all the above solutions, however none of them worked. If you're on linux/macOS i highly suggest using tsocks over an ssh tunnel. What you need in order to get this setup working is a machine where you can log in via ssh, and in addition to that a programm called tsocks installed.
The idea here is to create a dynamic tunnel via SSH (a socks5 proxy). We then configure tsocks to use this tunnel and to start our applications, in this case:
or to account for rails 3.0:
A more detailed guide can be found under:
http://blog.byscripts.info/2011/04/bypass-a-proxy-with-ssh-tunnel-and-tsocks-under-ubuntu/
Despite being written for Ubuntu the procedure should be applicable for all Unix based machines. An alternative to tsocks for Windows is FreeCap (http://www.freecap.ru/eng/). A viable SSH client on windows is called putty.
快速回答:添加带有安装/更新参数的代理配置
Quick answer : Add proxy configuration with parameter for both install/update
这完全有效:
This totally worked:
我在工作中一直使用 cntlm (http://cntlm.sourceforge.net/)。 配置与 ntlmaps 非常相似。
效果很好,还允许我连接我的 Ubuntu 盒子到 ISA 代理。
查看 http://cntlm.wiki.sourceforge.net/ 了解更多信息
I've been using cntlm (http://cntlm.sourceforge.net/) at work. Configuration is very similar to ntlmaps.
Works great, and also allows me to connect my Ubuntu box to the ISA proxy.
Check out http://cntlm.wiki.sourceforge.net/ for more information
我尝试了其中一些解决方案,但没有一个有效。 我终于找到了一个适合我的解决方案:
使用
-p
参数来传递代理。 我使用的是 Gem 版本 1.9.1。I tried some of these solutions, and none of them worked. I finally found a solution that works for me:
using the
-p
parameter to pass the proxy. I'm using Gem version 1.9.1.创建一个 .gemrc 文件(在 /etc/gemrc 或 ~/.gemrc 中,或者例如在 /opt/chef/embedded/etc/gemrc 中使用 Chef gem),其中包含:
然后您可以
gem install
作为通常。Create a .gemrc file (either in /etc/gemrc or ~/.gemrc or for example with chef gem in /opt/chef/embedded/etc/gemrc) containing:
Then you can
gem install
as usual.这完美地解决了我的问题:
您可能需要向其中添加您的用户名和密码:
This solved my problem perfectly:
You might need to add your user name and password to it:
如果您在通过代理进行身份验证时遇到问题,请务必按照以下格式设置环境变量:
user:password@
语法似乎不起作用,而且还有一些命名错误的语法Stack Overflow 和各种论坛帖子上浮动的环境变量。另请注意,您的宝石可能需要一段时间才能开始下载。 起初我以为它不起作用,但只要有一点耐心,他们就开始按预期下载。
If you are having problems getting authenticated through your proxy, be sure to set the environment variables in exactly the format below:
The
user:password@
syntax doesn't seem to work and there are also some badly named environment variables floating around on Stack Overflow and various forum posts.Also be aware that it can take a while for your gems to start downloading. At first I thought it wasn't working but with a bit of patience they started downloading as expected.
对于 Windows 操作系统,我使用 Fiddler 来解决该问题。
运行 gem:
For the Windows OS, I used Fiddler to work around the issue.
Run gem:
我无法通过命令行开关让我的工作正常工作,但我只需通过设置我的
HTTP_PROXY
环境变量就可以做到这一点。 (请注意,大小写似乎很重要)。 我有一个批处理文件,其中有这样一行:显然,在到达这一行之前,我设置了四个引用的变量。 举个例子,如果我的用户名是“wolfbyte”,我的密码是“secret”,我的代理称为“pigsy”并在端口 8080 上运行:
您可能需要小心管理方式,因为它将您的密码以纯文本形式存储在机器的会话,但我认为这不应该是一个太大的问题。
I wasn't able to get mine working from the command-line switch but I have been able to do it just by setting my
HTTP_PROXY
environment variable. (Note that case seems to be important). I have a batch file that has a line like this in it:I set the four referenced variables before I get to this line obviously. As an example if my username is "wolfbyte", my password is "secret" and my proxy is called "pigsy" and operates on port 8080:
You might want to be careful how you manage that because it stores your password in plain text in the machine's session but I don't think it should be too much of an issue.
关于这个主题的帖子比比皆是,为了帮助其他人节省尝试不同解决方案的时间,以下是我经过数小时修改后的最终结果。
目前互联网上的三种解决方案是:
红宝石
应用程序服务器
cntlm
rubysspi 只能在 Windows 计算机上运行,据我所知,因为它依赖于 Win32Api 库。 因此,如果您在 Windows 机器上尝试通过代理运行,那么这就是适合您的解决方案。 如果您使用的是 Linux 发行版,那么您就不走运了。
apserver 似乎是一个死项目。 我见过的帖子中列出的链接指向 sourceforge 上的 404 页面。 我在 sourceforge 上搜索“apserver”没有返回任何内容。
我看到的 cntlm 的 sourceforge 链接重定向到 http://cntlm.awk.cz/,但是超时了。 在 sourceforge 上搜索会发现此链接,该链接确实有效: http://sourceforge.net/projects/cntlm/< /a>
下载并配置 cntlm 后,我成功地通过代理安装了 gem,所以这似乎是 Linux 发行版的最佳解决方案。
Posts abound regarding this topic, and to help others save hours of trying different solutions, here is the final result of my hours of tinkering.
The three solutions around the internet at the moment are:
rubysspi
apserver
cntlm
rubysspi only works from a Windows machine, AFAIK, as it relies on the Win32Api library. So if you are on a Windows box trying to run through a proxy, this is the solution for you. If you are on a Linux distro, you're out of luck.
apserver seems to be a dead project. The link listed in the posts I've seen lead to 404 page on sourceforge. I search for "apserver" on sourceforge returns nothing.
The sourceforge link for cntlm that I've seen redirects to http://cntlm.awk.cz/, but that times out. A search on sourceforge turns up this link, which does work: http://sourceforge.net/projects/cntlm/
After downloading and configuring cntlm I have managed to install a gem through the proxy, so this seems to be the best solution for Linux distros.
解决方法是安装 http://web。在本地计算机上的 archive.org/web/20060913093359/http://apserver.sourceforge.net:80/ 上,配置它并通过此代理运行 gems。
PARENT_PROXY
和PARENT_PROXY_PORT
中。 输入“域”和“用户”的值。 将 PASSWORD 留空(冒号后不输入任何内容)——启动时系统会提示您。gem install—http-proxy http://localhost:5865/library
A workaround is to install http://web.archive.org/web/20060913093359/http://apserver.sourceforge.net:80/ on your local machine, configure it and run gems through this proxy.
PARENT_PROXY
andPARENT_PROXY_PORT
. Enter the values for DOMAIN and USER. Leave PASSWORD blank (nothing after the colon) – you will be prompted when launching it.cd aps097; python main.py
gem install—http-proxy http://localhost:5865/ library
rubysspi-1.3.1 在 Windows 7 上为我工作,使用此页面中的说明:
http:// /www.stuartellis.eu/articles/installing-ruby/
rubysspi-1.3.1 worked for me on Windows 7, using the instructions from this page:
http://www.stuartellis.eu/articles/installing-ruby/
如果您使用的是 *nix 系统,请使用以下命令:
然后尝试:
If you are on a *nix system, use this:
and then try:
我在代理后面工作,刚刚通过直接从 http://rubygems.org 下载来安装 SASS。
然后我运行 sudo gem install [path/to/downloaded/gem/file]。 我不能说这适用于所有宝石,但它可能对某些人有帮助。
I am working behind a proxy and just installed SASS by downloading directly from http://rubygems.org.
I then ran
sudo gem install [path/to/downloaded/gem/file]
. I cannot say this will work for all gems, but it may help some people.这在 Windows 环境中对我有用:
我有一个包含这些行的批处理文件,我可以在需要时使用它来设置环境值。
就我而言,诀窍是
HTTPS_PROXY
设置。 如果没有它们,我总是会收到 407 代理身份验证错误。This worked for me in a Windows box:
I have a batch file with these lines that I use to set environment values when I need it.
The trick, in my case, was
HTTPS_PROXY
sets. Without them, I always got a 407 proxy authentication error.如果你想使用 SOCKS5 代理,你可以尝试 rubygems-socksproxy https://github.com/gussan/rubygems -socksproxy。
它适用于我的 OSX 10.9.3。
If you want to use SOCKS5 proxy, you may try rubygems-socksproxy https://github.com/gussan/rubygems-socksproxy.
It works for me on OSX 10.9.3.