前言
因?yàn)樾〕绦蛏蟼餍枰猦ttps拿诸,服務(wù)器https用的是letsencrypt生成的證書搪搏,但是阿里云oss沒有做https(懶得上傳證書),就想著用Nginx代理轉(zhuǎn)發(fā)上傳請(qǐng)求。
Nginx配置
# HTTPS server
#
server {
listen 443 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ì)失敗;