背景
公司全部網(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í)有所幫助,也希望大家多多支持腳本之家。
標(biāo)簽:紅河 湛江 巴彥淖爾 回訪 廊坊 廣安 德州 滁州
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Nexus使用nginx代理實(shí)現(xiàn)支持HTTPS協(xié)議》,本文關(guān)鍵詞 Nexus,使用,nginx,代理,實(shí)現(xiàn),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。