使用 Squid 添加 HTTP 请求标头

bob*_*lin 5 google squid http-headers application

我想允许我的用户仅为我的域登录 Google 应用程序。我通过添加此 Google 帮助页面中X-GoogApps-Allowed-Domains所述的 HTTP 标头找到了解决方案。

我使用 Squid,但不知道如何配置 Squid 来执行此操作。如何使用 Squid 添加此请求标头?

小智 7

您可以使用支持命令“request_header_add”的新 Squid 3.3。我使用 CentOS 来做这件事。

我的 Squid.conf 是:

acl CONNECT method CONNECT
visible_hostname MySERVER.local
acl local src 192.168.0.0/24
http_access allow local
ssl_bump client-first all
always_direct allow all
http_port 3128 ssl_bump generate-host-certificates=on dynamic_cert_mem_cache_size=4MB cert=/usr/local/squid/etc/cert.pem
request_header_add X-GoogApps-Allowed-Domains "mycompany.com" all
cache_dir ufs /usr/local/squid/var/cache 8192 32 256
Run Code Online (Sandbox Code Playgroud)

对于SSL证书,是否需要用openSSL生成:

openssl req -new -newkey rsa:1024 -days 36500 -nodes -x509 -keyout /usr/local/squid/etc/cert.pem -out /usr/local/squid/etc/cert.pem 
Run Code Online (Sandbox Code Playgroud)

对于用户无法在浏览器中查看错误的情况,请将其安装为每台计算机中受信任的 root 或添加到您的 Active Directory 中(谷歌可能会对此有所帮助)。

openssl x509 -in /usr/local/squid/etc/cert.pem -outform DER -out /usr/local/squid/etc/cert.der
Run Code Online (Sandbox Code Playgroud)


Ric*_*ler 3

根据鱿鱼常见问题解答

Squid.conf ACL

通过 Squid ACL 进行的标头修改仅限于删除标头或用常量字符串替换匹配的标头。

换句话说,您无法仅使用 Squid ACL 添加任意请求标头。Squid ACL 限制您删除现有标头或替换现有标头,但不允许添加新标头。添加新标头的唯一方法是结合使用 ICAP 服务器和 Squid。有关详细信息,请参阅Squid 常见问题解答中的ICAP 部分。

  • 好吧,这个答案不再正确。 (3认同)