Secure Forward
Secure Forward是Fluentd所提供的一種串連兩個Fluentd的方式。讓遠端與近端的兩個Fluentd可以串連Input與Output資料,中間就以Secure Forward作為安全通道。
Secure Forward有點像VPN的概念,中間主要以SSL的方式作為連線通道,因此設定上可以指定SSL的金鑰位置,如果未指定,系統會自動建立一組金鑰,供雙方連線使用。
Server端設定
在Server端的設定部份,可以加上下面的設定,其中port為指定Secure Forward所開放的端口,讓外部可以連線...,而cert_auto_generate是提供自動產生SSL金鑰的方式,讓Server, Cluent雙方自動建立連線憑證:
<source>
type secure_forward
port 24284
bind 0.0.0.0
shared_key notasecret
self_hostname simon-debian6
cert_auto_generate yes
allow_anonymous_source no
<client>
host 211.78.245.67
</client>
</source>
Fluentd官方網站亦提供透設定憑證(pem)跟金鑰(CA)位置的方法,
<source>
type secure_forward
shared_key secret_string
self_hostname server.fqdn.local
secure true
ca_cert_path /path/to/certificate/ca_cert.pem
ca_private_key_path /path/to/certificate/ca_key.pem
ca_private_key_passphrase passphrase_for_private_CA_secret_key
authentication yes # Deny clients without valid username/password
...(skip)
</source>
關於key的generate方式,可以使用fluentd所提供的secure-forward-ca-generate的指令,位置在td-agent安裝目錄下的"./embedded/lib/ruby/gems/2.1.0/bin/"目錄中,指令如下:
simonsu@simon-debian6:/opt/google-fluentd$ ./embedded/lib/ruby/gems/2.1.0/bin/secure-forward-ca-generate /tmp/ notasecret
上面第二個參數是ca key所產生的目的目錄,第三個是passphrase...
而在認證用戶端,有透過user的認證方式以及透過IP鎖定的方式,下面是透過user帳號密碼認證:
<source>
type secure_forward
shared_key secret_string
self_hostname server.fqdn.local
secure true
ca_cert_path /path/to/certificate/ca_cert.pem
ca_private_key_path /path/to/certificate/ca_key.pem
ca_private_key_passphrase passphrase_for_private_CA_secret_key
authentication yes # Deny clients without valid username/password
<user>
username tagomoris
password foobar012
</user>
<user>
username frsyuki
password yakiniku
</user>
</source>
下面是透過Client IP位置認證:
<source>
type secure_forward
shared_key secret_string
self_hostname server.fqdn.local
secure true
ca_cert_path /path/to/certificate/ca_cert.pem
ca_private_key_path /path/to/certificate/ca_key.pem
ca_private_key_passphrase passphrase_for_private_CA_secret_key
allow_anonymous_source no # Allow to accept from nodes of <client>
<client>
host 192.168.10.30
# network address (ex: 192.168.10.0/24) NOT Supported now
</client>
<client>
host your.host.fqdn.local
# wildcard (ex: *.host.fqdn.local) NOT Supported now
</client>
</source>
Client端設定
而Client端的設定,則是透過output plugin的設定,設定secure_forward直接指向遠端的server位置。
<source>
type http
port 9880
</source>
<match **>
type copy
<store>
type stdout
</store>
<store>
type secure_forward
shared_key notasecret
self_hostname micloud-docker-registry-01
secure true
ca_cert_path /path/to/certificate/ca_cert.pem
<server>
host 104.199.154.208
port 24284
</server>
</store>
</match>