Kong 與 Nginx 設定關係筆記

工作上遇到一些狀況,需要處理 HTTPS 加解密演算法,剛好趁這個機會記錄一下 Kong 跟 Nginx 的關係。

這邊以 SSL Ciphers 為例,整理 Kong 設定如何流向至 Nginx 實際生效的過程。

概念架構

Kong 的設定與 Nginx 的設定之間存在著三層結構:

層級檔案位置用途
源頭kong.confKong 的主設定檔,定義所有運行參數
入口nginx.confNginx 的起點,僅做全域/事件設定,在 http {} 內 include 真正的設定檔
生效nginx-kong.conf實際生效的設定,包含 ssl_ciphers、ssl_protocols、各個 listen 等 TLS/Server 設定

簡單來說:kong.conf 是來源、nginx.conf 是入口、nginx-kong.conf 是實際生效結果。

設定流向 - 以 SSL Ciphers 為例

Step 1: 源設定

kong.conf 設定 ssl_cipher_suite 和 ssl_ciphers:

ssl_cipher_suite = custom
ssl_ciphers = ECDHE-RSA-AES256-GCM-SHA384:...

Step 2: Kong 翻譯

當你執行 kong startkong restart 時,Kong 會根據 kong.conf 生成 Nginx 的實際設定。

Step 3: Nginx 生效

真正生效的內容會被寫入 nginx-kong.conf,包含翻譯後的 ssl_ciphers、ssl_protocols 等設定。