35 lines
1.1 KiB
Plaintext
35 lines
1.1 KiB
Plaintext
|
|
# 云服务器 hjf.suzhouyuqi.com 站点 Nginx 配置示例
|
|||
|
|
# 用于宝塔/LNMP:复制到站点配置或 include 使用
|
|||
|
|
# 关键:root 指向 public,静态文件 /static/、/assets/、/pages/ 由 Nginx 直接提供
|
|||
|
|
|
|||
|
|
server {
|
|||
|
|
listen 80;
|
|||
|
|
listen 443 ssl http2;
|
|||
|
|
server_name hjf.suzhouyuqi.com;
|
|||
|
|
root /www/wwwroot/hjf.suzhouyuqi.com/public;
|
|||
|
|
index index.html index.php;
|
|||
|
|
|
|||
|
|
# SSL 证书(宝塔通常自动配置)
|
|||
|
|
# ssl_certificate ...
|
|||
|
|
# ssl_certificate_key ...
|
|||
|
|
|
|||
|
|
# H5 静态资源:直接由 Nginx 提供,避免返回 HTML 导致 "Unexpected token '<'"
|
|||
|
|
location ~ ^/(static|assets|pages)/ {
|
|||
|
|
try_files $uri =404;
|
|||
|
|
expires 7d;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# PHP 请求(按现有 Swoole/php-fpm 配置)
|
|||
|
|
location ~ \.php$ {
|
|||
|
|
proxy_pass http://127.0.0.1:20199;
|
|||
|
|
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 / {
|
|||
|
|
try_files $uri $uri/ /index.php?$query_string;
|
|||
|
|
}
|
|||
|
|
}
|