我试图将一个内部的GitLab安装与一个Slack传入的webhook集成在一起,但是我有一个问题,那就是GitLab只能访问同一个networking中的其他机器的机器。 我有虚拟机在同一个networking,并有外部访问。
Slack的webhook是这样一个URL:
https://hooks.slack.com/services/T18QMD0NM/C09PY5XKO/52lDzmkoxL51p9NLRqxQ9Kq2
但是因为我不能在GitLab中使用它,所以我已经在GitLab上configuration了Slack服务来向下面的URL发出请求:
https://192.168.1.220:3128/services/T18QMD0NM/C09PY5XKO/52lDzmkoxL51p9NLRqxQ9Kq2
虚拟机的IP地址是192.168.1.220 ,Squid正在监听的地址是3128 。
如何使用Squid将所有传入请求转发到hooks.slack.com ?
PS:我有一个干净的Squid安装,根本没有改变任何设置。
我想解决你的问题的最好方法是指导你的GitLab使用一个出站http代理。
你可以参考这个链接在你的GitLab安装上configurationhttp代理。
– 更新
#!/usr/bin/perl use strict; # Turn off buffering to STDOUT $| = 1; # Read from STDIN while (<>) { my @elems = split; # splits $_ on whitespace by default # The URL is the first whitespace-separated element. my $url = $elems[0]; # Handle local IP links and translate them to https://hooks.slack.com # with the rest of the URL intact (if present) and ignore warnings. # 192.168.1.220:3128 if ($url =~ m#^https://192\.168\.1\.220(/.*)?#i) { $url = "https://hooks.slack.com${1}"; print "$url\n"; } }
在squid.conf文件中添加以下代码行:
redirect_program /path/to/the/script/above/redirect_program.pl
最后使用以下命令重新加载/重新configurationsquid:
/path/to/executable/squid -k reconfigure