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-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
https://api.humanchan.me/ 应该是会转发到 https://www.humanchan.me/api/ 但是一直不成功,是我写错了么,还是应该怎么写
上面这个server针对api.humanchan.me这个域名,所以下面写的/api/那块没什么用,再说现在这个配置对于api.humanchan.me都会301到www.humanchan.me/api/,有什么问题吗?