1.概述
trino默(mo)認的(de)jdbc,cli及(ji)web ui等客戶(hu)端均封裝的(de)是http協議,且(qie)無(wu)法使用(yong)密碼,即非安全鏈(lian)接,如下圖所示:

如果(guo)這個時候傳輸密碼(ma)(ma)到(dao)服務端(duan)(duan),會(hui)拋(pao)出Authentication over HTTP is not enabled 異常(chang),當然(ran)也可以(yi)修改(gai)源碼(ma)(ma)支持http+密碼(ma)(ma)的(de)方式訪問trino,但(dan)是(shi)稍微復(fu)雜一些(xie),服務端(duan)(duan)和(he)客戶端(duan)(duan)都需要改(gai)造,如果(guo)是(shi)外接的(de)系統比(bi)如BI就比(bi)較麻煩(fan)。在不(bu)修改(gai)源碼(ma)(ma)的(de)情況(kuang)下,如果(guo)想要使用用戶名+密碼(ma)(ma)的(de)方式訪問trino, 那就必須啟用https。
非安(an)全鏈接配置比較(jiao)簡單(dan)可參(can)考trino官網,下面我們探討一下trino https鏈接
2.https 鏈接
trino支持三種(zhong)方式的https鏈接,分別是(shi):通過代理服(fu)務https訪問trino, 基于私有證(zheng)書的https,基于通用證(zheng)書的https
2.1通過代理服務https訪問trino
這是(shi)官方最推(tui)薦的方式,只需要在coordinator config.properties加如下(xia)配(pei)置:
http-server.process-forwarded=true
然后即可通過前端(duan)(duan)的(de)(de)(de)負載均衡或者代理服務訪問(wen)后端(duan)(duan)的(de)(de)(de)trino coordinator, 這個時候trino coordinator不需(xu)要配(pei)(pei)置(zhi)https,還是默認的(de)(de)(de)http配(pei)(pei)置(zhi),只需(xu)要前端(duan)(duan)的(de)(de)(de)代理https是基于(yu)通用證書即可,客戶(hu)端(duan)(duan)訪問(wen)代理的(de)(de)(de)https接口將信息(xi)轉發到后端(duan)(duan)的(de)(de)(de)trino server,如下圖(tu)所(suo)示:

2.2 基于私有證書的https
一般(ban)生(sheng)產環境也(ye)會使用(yong)這種方式,需(xu)要(yao)自己生(sheng)成證(zheng)書
1.生成證書:
http-server.https.port=8443
http-server.https.keystore.path=etc/trino.jks
http-server.https.keystore.key=${password}
http-server.authentication.type=password

touch password.db
htpasswd -B -C 10 password.db trino
然后輸入密碼即可
2.3 基于通用證書的https
需要(yao)申請通(tong)(tong)(tong)(tong)用(yong)證(zheng)書(shu),trino使用(yong)通(tong)(tong)(tong)(tong)用(yong)證(zheng)書(shu)的配(pei)置(zhi)方(fang)(fang)法(fa)和2.2一(yi)樣,但是通(tong)(tong)(tong)(tong)用(yong)證(zheng)書(shu)一(yi)般(ban)有時間(jian)期限,超時需要(yao)重新申請,通(tong)(tong)(tong)(tong)用(yong)證(zheng)書(shu)支持(chi)所有形式的客戶端和瀏覽器的https連接,無需對客戶端做額外配(pei)置(zhi),也是官方(fang)(fang)比(bi)較推(tui)薦的。
申請鏈接:
//www.sslforfree.com/