求教nginx配置轉發
仅有的幸福
仅有的幸福 2017-05-16 17:07:02
0
1
503

server {
listen 443;
server_name localhost api.humanchan.me;
ssl on;
root html;
index index.html index.htm;

if ($http_host ~ "^api.humanchan.me$") {
rewrite ^(.*) https://www.humanchan.me/api/$1 permanent;
}

#location ^~ /api/ {

proxy_pass http://127.0.0.1:7001;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
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 $scheme;

}

}

https://api.humanchan.me/ 應該是會轉發到 https://www.humanchan.me/api/ 但一直不成功,是我寫錯了麼,還是該怎麼寫###
仅有的幸福
仅有的幸福

全部回覆(1)
刘奇

上面這個server針對api.humanchan.me這個域名,所以下面寫的/api/那塊沒什麼用,再說現在這個配置對於api.humanchan.me都會301到www.humanchan.me/api/,有什麼問題嗎?

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!