在現代日誌平台中,安全性是極為重要卻常被開發者忽略的一塊 (能動就好)。
Graylog 提供多層次的安全機制,協助保護系統與資料不受 未經授權 的存取或竄改。
在設計日誌系統時,需要留意以下三大面向:
Graylog 預設提供數個角色:Admin
、Reader
、Editor
等。
透過「角色型存取控制(Role-Based Access Control)」將權限分派給角色,再將角色指派給用戶或團隊。
# 建立自訂角色 example-role
curl -X POST "http://<graylog-url>:9000/api/roles" \
-u admin:<password> \
-H "Content-Type: application/json" \
-H "X-Requested-By: CLI" \
-d '{
"name": "example-role",
"description": "僅能讀取特定 Streams",
"permissions": ["streams:read","dashboards:read"]
}'
# 將角色指派給用戶
curl -X PUT "http://localhost:9000/api/users/<user-id>" \
-u admin:<password> \
-H "Content-Type: application/json" \
-H "X-Requested-By: CLI" \
-d '["example-role"]'
'{"roles": ["Reader", "example-role"]}'
graylog.crt
與私鑰 graylog.key
。server.conf
設定:
http_enable_tls = true
http_tls_cert_file = /etc/graylog/ssl/graylog.crt
http_tls_key_file = /etc/graylog/ssl/graylog.key
systemctl restart graylog-server
對於 Syslog、Beats 等輸入,可強制 TLS 連線,確保日誌傳輸過程加密。
在 server.conf
中啟用 LDAP:
auth_backend = ldap
ldap_hosts = ldap://ad.example.com:389
ldap_search_base = dc=example,dc=com
ldap_user_dn_pattern = cn={0},ou=Users,dc=example,dc=com
6.3 版本加入對 OIDC 的原生支援,能快速與 Keycloak、Okta 等身份服務整合:
# example oidc.conf
auth_service:
name: oidc
type: oidc
oidc_issuer_url: https://keycloak.example.com/auth/realms/demo
client_id: graylog-client
client_secret: somesecret
admin
密碼並移除預設帳號。透過以上幾個面向,能快速為 Graylog 環境建立起初步的防護與授權管理,降低遭受未授權存取或資料洩露的風險。
若需更進階的監控與防禦策略,可考慮結合 SIEM、WAF 等外部安全工具,並定期進行滲透測試與漏洞掃描。