Nexus使用nginx代理實現(xiàn)支持HTTPS協(xié)議
背景
公司全部網(wǎng)站需要支持 HTTPS 協(xié)議,在阿里云負載均衡配置 SSL 證書后,導(dǎo)致 Nexus 的 HTTPS 訪問出錯。
網(wǎng)站訪問路徑: 域名解析到阿里云的負載均衡,負載均衡配置 80 端口強轉(zhuǎn) 443 端口,443 端口配置 SSL 證書,并轉(zhuǎn)發(fā)到內(nèi)網(wǎng) nginx,內(nèi)網(wǎng)的 nginx 再代理 Nexus 服務(wù)。
解決
瀏覽器 HTTPS 訪問 Nexus 的 Console 報錯信息:

報錯信息大致意思是:HTTPS 訪問的頁面上不允許出現(xiàn) HTTP 請求。
解決方法: 在 nginx 配置文件增加 “proxy_set_header X-Forwarded-Proto https;” ,這樣 nginx 在轉(zhuǎn)發(fā)時就使用 HTTPS 協(xié)議。
nginx.conf 中的 nexus 配置內(nèi)容:
location ^~ /nexus {
proxy_pass http://x.x.x.x:8080/nexus;
sendfile off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https; # 轉(zhuǎn)發(fā)時使用https協(xié)議
proxy_max_temp_file_size 0;
# This is the maximum upload size
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_temp_file_write_size 64k;
# Required for new HTTP-based CLI
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_buffering off; # Required for HTTP-based CLI to work over SSL
}
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持本站。
版權(quán)聲明:本站文章來源標注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信