✔通过访问二级目录来访问后台
server {
listen 80;
server_name api.imwoniu.com;
#通过访问backend二级目录来访问后台
location /backend/ {
#BackendService后面的斜杠是一个关键,没有斜杠的话就会传递backend到后端节点导致404
proxy_pass http://BackendService/;
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;
}
#其他路径默认访问前台网站
#location / {
# proxy_pass http://FrontPage;
# 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;
#}
}
#简单的负载均衡节点配置
upstream BackendService {
server 127.0.0.1:9292;
# ip_hash;
}
#upstream FrontPage {
# server 127.0.0.1;
# # ip_hash;
#}
网友评论