feat(): add custom error pages support
parent
c8a5ab87d3
commit
7f93f5fbd0
10
README.md
10
README.md
|
@ -134,6 +134,16 @@ docker exec -ti flarum extension remove some/extension
|
|||
docker exec -ti flarum extension list
|
||||
```
|
||||
|
||||
### Custom error pages
|
||||
|
||||
To use custom error pages, add your .html files in `/mnt/docker/flarum/assets/errors` folder :
|
||||
|
||||
```
|
||||
mkdir -p /mnt/docker/flarum/assets/errors
|
||||
touch 403.html 404.html 500.html 503.html
|
||||
chown -R 991:991 /mnt/docker/flarum
|
||||
```
|
||||
|
||||
### Screenshot
|
||||
|
||||
#### Installation
|
||||
|
|
63
nginx.conf
63
nginx.conf
|
@ -58,46 +58,77 @@ http {
|
|||
root /flarum/app;
|
||||
index index.php;
|
||||
charset utf-8;
|
||||
|
||||
client_max_body_size 50M;
|
||||
fastcgi_buffers 64 4K;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
error_page 403 /403.html;
|
||||
error_page 404 /404.html;
|
||||
error_page 500 /500.html;
|
||||
error_page 503 /503.html;
|
||||
|
||||
location /api {
|
||||
try_files $uri $uri/ /api.php?$query_string;
|
||||
}
|
||||
location = /403.html { root /flarum/app/vendor/flarum/core/error; }
|
||||
location = /404.html { root /flarum/app/vendor/flarum/core/error; }
|
||||
location = /500.html { root /flarum/app/vendor/flarum/core/error; }
|
||||
location = /503.html { root /flarum/app/vendor/flarum/core/error; }
|
||||
|
||||
location /admin {
|
||||
try_files $uri $uri/ /admin.php?$query_string;
|
||||
}
|
||||
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 {
|
||||
# Access path list
|
||||
# --------------------------------------
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
return 404;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
location ~* ^/(Procfile|storage|Vagrantfile|config\.php|LICENSE|vendor|flarum|scripts) {
|
||||
deny all;
|
||||
return 404;
|
||||
}
|
||||
|
||||
location ~* \.html$ {
|
||||
location ~* composer(.*?) {
|
||||
deny all;
|
||||
return 404;
|
||||
}
|
||||
|
||||
location ~* (.*?)\.md {
|
||||
deny all;
|
||||
return 404;
|
||||
}
|
||||
|
||||
# Assets cache control
|
||||
# --------------------------------------
|
||||
location ~* \.(?:html|xml|json)$ {
|
||||
expires -1;
|
||||
}
|
||||
|
||||
location ~* \.(css|js|gif|jpe?g|png)$ {
|
||||
expires 1M;
|
||||
location ~* \.(?:css|js)$ {
|
||||
expires 7d;
|
||||
add_header Pragma public;
|
||||
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
|
||||
}
|
||||
|
||||
location ~* \.(?:gif|jpe?g|png|ico|otf|eot|svg|ttf|woff|woff2)$ {
|
||||
expires 30d;
|
||||
add_header Pragma public;
|
||||
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
|
||||
}
|
||||
|
||||
# PHP Backend
|
||||
# --------------------------------------
|
||||
location ~* \.php$ {
|
||||
fastcgi_split_path_info ^(.+.php)(/.+)$;
|
||||
fastcgi_pass unix:/tmp/php-fpm.sock;
|
||||
try_files $uri =404;
|
||||
include fastcgi_params;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_index index.php;
|
||||
fastcgi_pass unix:/tmp/php-fpm.sock;
|
||||
fastcgi_intercept_errors on;
|
||||
fastcgi_request_buffering off;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
5
run.sh
5
run.sh
|
@ -28,6 +28,11 @@ chown -R $UID:$GID /flarum /etc/nginx /etc/php7 /var/log /var/lib/nginx /tmp /et
|
|||
|
||||
cd /flarum/app
|
||||
|
||||
if [ -d 'assets/errors' ]; then
|
||||
rm -rf vendor/flarum/core/error/*
|
||||
ln -s /flarum/app/assets/errors/* vendor/flarum/core/error
|
||||
fi
|
||||
|
||||
# if no installation was performed before
|
||||
if [ -e 'assets/rev-manifest.json' ]; then
|
||||
|
||||
|
|
Loading…
Reference in New Issue