# 重写
location / {
index index.php index.html index.htm;
# 如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last;
}
}
# api重写
location /api/ {
index index.php index.html index.htm;
# 如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
if (!-e $request_filename)
{
rewrite ^/api/(.*)$ /api.php?s=$1 last;
}
}
# 静态文件目录禁止执行php
location ~* ^\/static\/.+\.(php)$ {
return 404;
}
# 指定目录禁止执行html和php
location ~* ^\/(upload|plugins|themes)\/.+\.(html|php)$ {
return 404;
}
# websocket代理
location /ws {
proxy_pass http://0.0.0.0:2345;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}