前言
因?yàn)樾〕绦蛏蟼餍枰猦ttps,服務(wù)器https用的是letsencrypt生成的證書,但是阿里云oss沒有做https(懶得上傳證書),就想著用Nginx代理轉(zhuǎn)發(fā)上傳請求 。
Nginx配置
# HTTPS server# server {listen443 ssl;server_name your.domain.name;...location / {proxy_pass http://127.0.0.1:3000;proxy_set_header Host $Host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For}location /oss {proxy_set_header Host drift-book-dev.oss-cn-shenzhen.aliyuncs.com;proxy_set_header Connection keep-alive;proxy_pass http://***.oss-cn-***.aliyuncs.com/;#proxy_set_header X-Real-IP $remote_addr;#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;} }這里使用子path"/oss"做轉(zhuǎn)發(fā)路徑 。
proxy_pass 指定 你的阿里云域名,記得后面一定要帶斜杠"/",不然轉(zhuǎn)發(fā)會(huì)失敗;
nginx配置proxy_pass代理轉(zhuǎn)發(fā)
假設(shè)下面四種情況分別用 http://192.168.1.1/proxy/test.html 進(jìn)行訪問 。
第一種:
location /proxy/ {proxy_pass http://127.0.0.1/; } 代理到URL:http://127.0.0.1/test.html
第二種(相對于第一種,最后少一個(gè) / )
location /proxy/ {proxy_pass http://127.0.0.1; } 代理到URL:http://127.0.0.1/proxy/test.html
第三種:
location /proxy/ {proxy_pass http://127.0.0.1/aaa/; } 代理到URL:http://127.0.0.1/aaa/test.html
第四種(相對于第三種,最后少一個(gè) / )
location /proxy/ {proxy_pass http://127.0.0.1/aaa; } 代理到URL:http://127.0.0.1/aaatest.html
【Nginx 代理轉(zhuǎn)發(fā)阿里云OSS上傳的實(shí)現(xiàn)代碼,阿里云OSS上傳代理轉(zhuǎn)發(fā)案例教程】以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持 。
Nginx 代理轉(zhuǎn)發(fā)阿里云OSS上傳的實(shí)現(xiàn)代碼,阿里云OSS上傳代理轉(zhuǎn)發(fā)案例教程
推薦閱讀
- centos8安裝nginx1.9.1的詳細(xì)過程,nginx1.9.1安裝教程介紹
- nginx反向代理配置去除前綴案例教程,nginx反向代理配置教程
- 2018做聚合支付代理加盟有前景嗎 中國銀聯(lián)聚合支付代理加盟
- Nginx源碼研究之nginx限流模塊詳解說明
- 在centos7中安裝nginx的詳細(xì)教程方法
- linux系統(tǒng)shell腳本定時(shí)統(tǒng)計(jì)Nginx下access.log的PV并發(fā)送給API保存到數(shù)據(jù)庫
- nginx下配置openssl實(shí)現(xiàn)https的方法
- 淺談nginx反向代理中神奇的斜線
- 開一家智能家居店需要多少錢,智能家居代理的費(fèi)用大概是多少?
- Nginx配置Https安全認(rèn)證的解決方法
