如何为http代理设置squid并让git使用它?

时间:2017-01-23 06:55:54

标签: git proxy http-proxy squid

简介
我有一个http代理,其中有一个带有'@'的异常密码。我无法改变它。我必须只使用代理连接,即每个软件都必须使用代理,否则它们不起作用。

场合
我使用的是Ubuntu 16.04 我已使用用户名和密码设置gnome settings代理。我已设置/etc/environment文件以指定http代理。我已单独设置apt以使用代理设置。

上述所有配置都有一些共同点,'@'不是直接接受的,我不得不使用%40 来逃避它。要通过终端传递代理用户名,密码,地址和端口,我必须使用http://username:password@server:port。这里出现了问题,因为当我用@写密码时,大多数软件都会感到困惑。类似于pass@word

git问题
Link to how to make git work with http proxy
我将~/.gitconf文件设置如下:

  • 案例1:
  

[HTTP]
  proxy = http://user:pass@word@server:port

  • 案例2:
  

[HTTP]
  proxy = http://user:pass%40word@server:port

  • 案例3:
  

[HTTP]
  proxy = http://user:pass%%40word@server:port

所有这些都不起作用。

我在朋友的macOS Sierra中使用 squidman 设置父代理并设置git的代理以使用squidman正在侦听的端口并且git工作。

为了复制我在Ubuntu 16.04中安装squid的相同行为。
我已将squid.conf文件设置如下:

http_port 3128
cache_peer server parent port 0 no-query no-digest login=user:pass%%40word      
#as specified by squid config rules in comments

并将git proxy设置为

[http]
    proxy = localhost:3128

仍然让我无法连接到服务器

问题
如何正确设置Squid代理?

My details for proxy are like (they are invariants):
    Username: user
    Password: pass@54321
    Server: 192.25.5.6 //The server is in my network
    Port: 808

如何让git使用squid的代理?

参考资料不是必需的,但会非常有帮助。

1 个答案:

答案 0 :(得分:0)

git配置文件名为“ .gitconfig”,而不是您在问题中提到的“ .gitconf”。这可能就是为什么您的设置无法按预期运行的原因