docker-flarum/rootfs/nginx/sites-enabled/flarum.conf

79 lines
1.9 KiB
Plaintext

server {
listen 8888;
root /flarum/app;
index index.php;
charset utf-8;
fastcgi_buffers 64 4K;
error_page 403 /403.html;
error_page 404 /404.html;
error_page 503 /503.html;
location = /403.html { root /flarum/app/vendor/flarum/core/error; }
location = /404.html { root /flarum/app/vendor/flarum/core/error; }
location = /503.html { root /flarum/app/vendor/flarum/core/error; }
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; }
# Access path list
# --------------------------------------
location ~ /\. {
deny all;
return 404;
}
location ~* ^/(Procfile|storage|Vagrantfile|config\.php|LICENSE|vendor|flarum|scripts) {
deny all;
return 404;
}
location ~* composer(.*?) {
deny all;
return 404;
}
location ~* (.*?)\.md {
deny all;
return 404;
}
# Assets cache control
# --------------------------------------
location ~* \.(?:html|xml|json)$ {
expires -1;
}
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$ {
try_files $uri =404;
include /nginx/conf/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:/php/run/php-fpm.sock;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
fastcgi_param REMOTE_ADDR $http_x_real_ip;
}
}