首頁  >  問答  >  主體

求教nginx配置轉發

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/ 但一直不成功,是我寫錯了麼,還是該怎麼寫###
仅有的幸福仅有的幸福2714 天前509

全部回覆(1)我來回復

  • 怪我咯

    怪我咯2017-05-16 17:09:02

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

    回覆
    0
  • 取消回覆