Nexus使用nginx代理實(shí)現(xiàn)支持HTTPS協(xié)議
背景
公司全部網(wǎng)站需要支持 HTTPS 協(xié)議,在阿里云負(fù)載均衡配置 SSL 證書后,導(dǎo)致 Nexus 的 HTTPS 訪問(wèn)出錯(cuò)。
網(wǎng)站訪問(wèn)路徑: 域名解析到阿里云的負(fù)載均衡,負(fù)載均衡配置 80 端口強(qiáng)轉(zhuǎn) 443 端口,443 端口配置 SSL 證書,并轉(zhuǎn)發(fā)到內(nèi)網(wǎng) nginx,內(nèi)網(wǎng)的 nginx 再代理 Nexus 服務(wù)。
解決
瀏覽器 HTTPS 訪問(wèn) Nexus 的 Console 報(bào)錯(cuò)信息:
報(bào)錯(cuò)信息大致意思是:HTTPS 訪問(wèn)的頁(yè)面上不允許出現(xiàn) HTTP 請(qǐng)求。
解決方法: 在 nginx 配置文件增加 “proxy_set_header X-Forwarded-Proto https;” ,這樣 nginx 在轉(zhuǎn)發(fā)時(shí)就使用 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ā)時(shí)使用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 }
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持本站。
版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。