Hi,
I have the following nginx config and it does the following things;
-
let you access files directly in /css, /fonts, /img, /js with a cache header
-
rewrite the rest to fastcgi with fastcgi_params (index.php?..)
daemon off;
events {
worker_connections 4096;
}http {
include mime.types;client_body_temp_path /tmp/nginx/client_body; proxy_temp_path /tmp/nginx/proxy; fastcgi_temp_path /tmp/nginx/fastcgi; uwsgi_temp_path /tmp/nginx/uwsgi; scgi_temp_path /tmp/nginx/scgi; client_body_buffer_size 1k; client_header_buffer_size 1k; client_max_body_size 1k; large_client_header_buffers 2 1k; daemon off;
events {
worker_connections 4096;
}http {
include mime.types;client_body_temp_path /tmp/nginx/client_body;
proxy_temp_path /tmp/nginx/proxy;
fastcgi_temp_path /tmp/nginx/fastcgi;
uwsgi_temp_path /tmp/nginx/uwsgi;
scgi_temp_path /tmp/nginx/scgi;client_body_buffer_size 1k;
client_header_buffer_size 1k;
client_max_body_size 1k;
large_client_header_buffers 2 1k;limit_conn_zone $binary_remote_addr zone=addr:5m;
limit_conn addr 10;access_log /tmp/nginx/logs/access.log;
server {
listen 8080;
root /www;
index index.php;server_tokens off; location ~ ^/(css|fonts|img|js)/ { #expires 30d; } location / { rewrite ^ /index.php break; fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params; fastcgi_param HTTP_PROXY ""; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass php-fpm; }
}
upstream php-fpm {
server php:8080;
} }limit_conn_zone $binary_remote_addr zone=addr:5m; limit_conn addr 10; access_log /tmp/nginx/logs/access.log; server { listen 8080; root /www; index index.php; server_tokens off; location ~ ^/(css|fonts|img|js)/ { #expires 30d; } location / { rewrite ^ /index.php break; fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params; fastcgi_param HTTP_PROXY ""; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass php-fpm; } } upstream php-fpm { server php:8080; }
}
Any idea how I would best inplement this in Caddy? Important thing here is that everything is redirected to fastcgi if not in /css,/fonts, etc.
So far I have:
gzip
minify
/css/,/fonts/,/img/,/js/ {
root /assets/
expires {
match .js$ 1d
match .css$ 1d
match .eaf$ 1m
}
}
fastcgi / php-fpm:8080 php