Skip to content

Nginx configuration for WebEngine CMS

Lautaro Angelico edited this page May 5, 2025 · 1 revision

Use the following configuration as a base to configure your own instance of WebEngine CMS running on a Nginx web server. Make sure to adjust the PHP version and paths according to your server setup.

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    index index.php index.html index.htm;
    server_name _;
	
    location ^~ /.well-known/ {
        allow all;
        root /var/www/html;
    }
	
    location ^~ /includes/ {
        deny all;
    }

    location ^~ /modules/ {
        deny all;
    }

    location ^~ /admincp/inc/ {
        deny all;
    }

    location ^~ /admincp/modules/ {
        deny all;
    }
	
    location / {

        try_files $uri $uri/ = 404;
		
        if ($request_uri ~* ^/admincp/?$) {
            break;
        }
		
        rewrite ^/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9-_\/]+)/?$ /index.php?page=$1&subpage=$2&request=$3 last;
        rewrite ^/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/?$ /index.php?page=$1&subpage=$2 last;
        rewrite ^/([a-zA-Z0-9]+)/?$ /index.php?page=$1 last;
    }
	
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/run/php/php8.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
	
    location ~ /\.ht {
        deny all;
    }
}

Clone this wiki locally