38 lines
1.0 KiB
Plaintext
38 lines
1.0 KiB
Plaintext
# 至少需要一个 Hyperf 节点,多个配置多行
|
||
upstream hyperf {
|
||
# Hyperf HTTP Server 的 IP 及 端口
|
||
server hyperf:9501;
|
||
}
|
||
|
||
server {
|
||
# 端口
|
||
listen 80;
|
||
# 域名
|
||
server_name demo.mineadmin.com;
|
||
# 日志
|
||
error_log /var/log/nginx/error.log error;
|
||
access_log /var/log/nginx/access.log;
|
||
|
||
# 同域根目录前端代码部署,注意:
|
||
location / {
|
||
root /usr/share/nginx/html;
|
||
try_files $uri $uri/ /index.html;
|
||
index index.html;
|
||
}
|
||
|
||
# 支持自定义下划线参数通过header传输
|
||
# underscores_in_headers on;
|
||
|
||
# PHP 代码
|
||
location /api/ {
|
||
# 将客户端的 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;
|
||
# 将协议架构转发到对应节点,如果使用非https请改为http
|
||
proxy_set_header X-scheme https;
|
||
|
||
# 执行代理访问真实服务器
|
||
proxy_pass http://hyperf/;
|
||
}
|
||
} |