upstream balance {
# Hyperf HTTP Server 的 IP 及 端口
server 127.0.0.1:10816;
# server 127.0.0.1:9502;
}
server {
# 监听端口
listen 80;
# 绑定的域名,填写您的域名
server_name balance.xiaotu.com;
location / {
# 将客户端的 Host 和 IP 信息一并转发到对应节点
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 转发Cookie,设置 SameSite
proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict";
# 执行代理访问真实服务器
proxy_pass http://balance;
}
}
~
虚拟机 配置
/etc/hosts
127.0.0.1 balance.xiaotu.com
修改本机host