Ask for advice on nginx configuration forwarding
仅有的幸福
仅有的幸福 2017-05-16 17:07:02
0
1
525

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/ should be forwarded to https://www.humanchan.me/api/ but it has been unsuccessful. Did I write it wrong or how should I write it

仅有的幸福
仅有的幸福

reply all(1)
刘奇

The server above targets the domain name api.humanchan.me, so the /api/ written below is of no use. Besides, this configuration now will 301 to www.humanchan.me/api/ for api.humanchan.me. What’s the problem? ?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template