如下两个代理,分别将 yuwei.cc 代理到 127.0.0.1:9000、yuwei.cc/api 代理到 127.0.0.1:9501:
server {
listen 80;
server_name yuwei.cc;
access_log logs/book.log;
error_log logs/book.error;
location / {
root html;
index index.php index.html;
proxy_pass http://127.0.0.1:9000; #这里的端口记得改成项目对应的哦
}
#将 /api 请求转发给 http://127.0.0.1:9501 处理
location /api {
proxy_pass http://127.0.0.1:9501; #这里的端口记得改成项目对应的哦
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
}
}