Setting up an Nginx web server for Coffee CMS

The Nginx web server does not support .htaccess files, so it cannot be automatically configured from the file included in the Coffee CMS archive. It will have to be configured manually.

The settings for this are given below. Look and twist.

map $sent_http_content_type $expires {
    default                 off;
    text/html               1d;
    application/javascript  7d;
    text/css                7d;
    image/png               7d;
    image/svg+xml           7d;
}
  
server {
    listen 80;
    server_name www.coffee-cms.com coffee-cms.com;
    return 301 https://coffee-cms.com$request_uri;
} 

server {
    listen 443 ssl http2;
    server_name www.coffee-cms.com;
    return 301 https://coffee-cms.com$request_uri;
    ssl_certificate /var/www/coffee-cms.com/coffee-cms.com.crt;
    ssl_certificate_key /var/www/coffee-cms.com/coffee-cms.com.key;
}

server {
    listen 443 ssl http2;
    server_name coffee-cms.com;
    root /var/www/coffee-cms.com/html;
    error_log /var/www/coffee-cms.com/error.log warn;
    access_log /var/www/coffee-cms.com/access.log;
    ssl_certificate /var/www/coffee-cms.com/coffee-cms.com.crt;
    ssl_certificate_key /var/www/coffee-cms.com/coffee-cms.com.key;
    expires 365d;
    gzip on;
    gzip_types text/html text/plain text/css application/json application/javascript;
    client_max_body_size 10m;
    location / {
        index index.html /.cms/index.php;
        # prevernt download pages as files
        default_type text/html;
        try_files $uri $uri/ /.cms/index.php?$query_string;
    }
    
    location ~ "/([^/]+\.(zip|gz))$" {
        add_header Content-disposition "attachment; filename=$1";
    }
    
    location ~ /\.(?!cms/index.php) {
 		deny  all;
 	}
    if ( $request_uri = "/.cms/index.php" ) {
        return 403;
    }

    location ~ \.php(/|$) {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        fastcgi_buffering off;
        fastcgi_request_buffering off;
        fastcgi_index index.php;
        include fastcgi.conf;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        expires off;
    }
    
    location /favicon.ico {
        return 204;
        access_log off;
        log_not_found off;
    }
}