AWS SSM 代理注册调用无法代理?

AWS SSM 代理注册调用无法代理?

我该如何代理amazon-ssm-agent -register呼叫?

我想代理所有amazon-ssm-agent流量本地虚拟机通过 squid 代理实例。

当 SSM 代理运行时,它似乎通过 squid 代理所有流量(如预期的那样)。但是,初始注册调用似乎没有经过代理。

例子:

鉴于具有以下规则的 squid 代理服务器(/etc/squid/squid.conf

acl whitelist dstdomain example.com
http_access allow whitelist

已配置(systemctl edit amazon-ssm-agent)aws-ssm-agent 的代理设置:

[Service]
Environment="http_proxy=http://localhost:3128"
Environment="https_proxy=http://localhost:3128"
Environment="no_proxy=169.254.169.254"

然后我希望以下内容失败因为代理不允许访问除example.com

> amazon-ssm-agent -register -code "abcdefghijklmnop" -id "aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaa" -region "eu-west-2"

但实际上它绕过代理并成功向 AWS 注册(/var/log/amazon/ssm/amazon-ssm-agent.log):

2019-01-11 14:44:57 DEBUG Start File Watcher On: /etc/amazon/ssm/seelog.xml
2019-01-11 14:44:57 DEBUG Start Watcher on directory: /etc/amazon/ssm
2019-01-11 14:45:55 INFO Successfully registered the instance with AWS SSM using Managed instance-id: mi-0000aa00000a0aaaa0

我如何确保该amazon-ssm-agent -register呼叫是通过 squid 代理的?

答案1

amazon-ssm-agent -register调用不是由 systemd 作为服务运行的,因此要代理调用register本身,您必须以通常的方式设置/导出代理属性。

> http_proxy="http://localhost:3128"
> https_proxy="http://localhost:3128"
> amazon-ssm-agent -register -code "abcdefghijklmnop" -id "aaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaa" -region "eu-west-2"

很简单。一旦你知道情况就是这样的 :)

相关内容