求教nginx配置转发
仅有的幸福
仅有的幸福 2017-05-16 17:07:02
0
1
502

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/ 但是一直不成功,是我写错了么,还是应该怎么写

仅有的幸福
仅有的幸福

全部回复(1)
刘奇

上面这个server针对api.humanchan.me这个域名,所以下面写的/api/那块没什么用,再说现在这个配置对于api.humanchan.me都会301到www.humanchan.me/api/,有什么问题吗?

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!