Clone wiki

CMS / Настройка Atom-M и Nginx

Пример конфигурации:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    access_log /var/www/logs/access.log;
    error_log /var/www/logs/error.log;

    root /var/www/htdocs;
    server_name 127.0.0.1;

    # Atom-M CMS

    index index.php;
    charset utf-8;
    error_page 404 /404;
    error_page 403 /403;
    autoindex off;

    location ~* ^/(data|template)/.+\.(php|php3|php4|php5|phtml|phar|phps|pl|pm)$ {
        deny all;
        return 404;
    }

    location ~ /modules/ {
        deny all;
        return 404;
    }

    location ~ ^/sys/(.*)/(.*)$ {
        deny all;
        return 404;
    }

    location ~ /sys/boot.php {
        deny all;
        return 404;
    }

    location ~ ^/admin/(.*)/(.*)$ {
        if (!-e $request_filename){
            rewrite ^(.*)$ /index.php?url=$1;
        }
    }

    location / {
        if ($http_host ~* "^www\.(.*)"){
            rewrite ^(.*)$ http://%1/$1 redirect;
        }
        rewrite ^/([404|403|402|ban|hack]+)$ /sys/error.php?ac=$1;
        if (!-e $request_filename){
            rewrite ^(.*)$ /index.php?url=$1;
        }
    }
    location /image {
        rewrite ^/image/(.*)/([full|small]+)/(.*)$ /sys/img.php?m=$1&t=$2&n=$3;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}

Updated