26 lines
716 B
Groff
26 lines
716 B
Groff
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
root /usr/share/nginx/html;
|
|
index index.html index.htm index.php;
|
|
|
|
# 统一PHP解析规则(所有目录下.php文件都交给php-fpm解析)
|
|
location ~ \.php$ {
|
|
fastcgi_pass php:9000;
|
|
fastcgi_index index.php;
|
|
# 自动获取当前请求php文件真实路径,支持任意php文件
|
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
include fastcgi_params;
|
|
}
|
|
|
|
# 前端静态页面、目录访问
|
|
location / {
|
|
try_files $uri $uri/;
|
|
}
|
|
|
|
# /api 仅路由,不用重复配置php,上面正则会自动处理
|
|
location /api/ {
|
|
try_files $uri $uri/;
|
|
}
|
|
}
|