miaomiao2014
加了 include /你的Flarum路径/.nginx.conf;
之后,不需要再加其他的 nginx 定向内容,default.conf 恢复至默认,或者删去你在里面加入的额外定向内容。
不需要再在默认定向文件中加入以下内容,论坛安装的根目录文件.nginx.conf
下已经包含:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /api {
try_files $uri $uri/ /api.php?$query_string;
}
location /admin {
try_files $uri $uri/ /admin.php?$query_string;
}
location /flarum {
deny all;
return 404;
}
location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
如果你加入了上面这段,请删除。
这是我的配置,你可以查看
在网站伪静态中加入:
include /www/wwwroot/xxx.xxx/.nginx.conf;
默认定向文件参考:
server
{
listen 80;
listen 443 ssl http2;
server_name xxx.xxx www.xxx.xxx;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/xxx.xxx/public;
#SSL-START
#error_page 404/404.html;
#HTTP_TO_HTTPS_START
if ($server_port !~ 443){
rewrite ^(/.*)$ https://$host$1 permanent;
}
#HTTP_TO_HTTPS_END
ssl_certificate /www/server/panel/vhost/cert/xxx.xxx/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/xxx.xxx/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000";
error_page 497 https://$host$request_uri;
#SSL-END
include /www/server/panel/vhost/nginx/redirect/xxx.xxx/*.conf;
#ERROR-PAGE-START
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START
include enable-php-80.conf;
#PHP-INFO-END
#REWRITE-START
include /www/server/panel/vhost/rewrite/xxx.xxx.conf;
#REWRITE-END
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
location ~ \.well-known{
allow all;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log /dev/null;
access_log /dev/null;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log /dev/null;
access_log /dev/null;
}
access_log /www/wwwlogs/xxx.xxx.log;
error_log /www/wwwlogs/xxx.xxx.error.log;
}