Как правильно настроить конфигурацию NGINX для работы MODX?

Столкнулся с проблемой запуска MODX Revo 2 на NGINX

При такой конфигурации сайт запускается, но запускается только главная страница, не работают дружественные URL, подскажите что нужно подправить или где об этом можно почитать, ресерч в Гугл дает устаревшую конфигурацию NGINX которая вообще не запускает сайт
server {
    # Тут и далее указать ваш ip сервера вместо 10.10.10.10;
    listen 213.139.209.81:80;
    
    # Тут и далее заменить my-site.ru на ваш домен
    server_name 213.139.209.81 www.213.139.209.81;
    return 301 https://213.139.209.81$request_uri;
}

server {
    listen 213.139.209.81:443 ssl http2;
	server_name 213.139.209.81 www.213.139.209.81;
	ssl_certificate "/var/www/httpd-cert/www-root/213.139.209.81_le1.crt";
	ssl_certificate_key "/var/www/httpd-cert/www-root/213.139.209.81_le1.key";
	ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
	ssl_prefer_server_ciphers on;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
	ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
	charset off;
	index index.php index.html;
	disable_symlinks if_not_owner from=$root_path;
	include /etc/nginx/vhosts-includes/*.conf;
	include /etc/nginx/vhosts-resources/213.139.209.81/*.conf;
	access_log /var/www/httpd-logs/213.139.209.81.access.log;
	error_log /var/www/httpd-logs/213.139.209.81.error.log notice;
	ssi on;
	set $root_path /var/www/www-root/data/www/213.139.209.81;
	root $root_path;
	gzip on;
	gzip_comp_level 5;
	gzip_disable "msie6";
	gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
	
	# Редирект с www на адрес без www
    if ($host ~* '^www\.(.*)$') {
        return 301 $scheme://$1$request_uri;
    }

    # Редирект с index.php на корень сайта:
    if ($request_uri ~* '^/index.php$') {
        return 301 /;
    }

    # Убираем повторяющиеся слеши из адреса
    # Вариант, работающий только при merge_slashes = on
    if ($request_uri ~ ^[^?]*//) {
        rewrite ^ $uri permanent;
    }
    # Универсальный вариант
    #if ($request_uri ~ ^(?P<left>[^?]*?)//+(?P<right>[^?]*)) {
    #    rewrite ^ $left/$right permanent;
    #}

    # Удаление слеша на конце всех URL, если необходимо.
    # Если изменили адрес админки MODX, то нужно указать его в условии этого правила, иначе будет бесконечный редирект.
    # if ($request_uri ~ ".*/$") {
    #    rewrite ^/((?!core|connectors|manager|setup).*)/$ /$1 permanent;
    # }

    # Запрет для всех для при обращении к ядру MODx из браузера
    location ~ ^/core/.* {
        deny all;
        return 403;
    }
    
    location ~ ^/config.core.php {
        return 404;
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }
	
	location / {
		location ~ [^/]\.ph(p\d*|tml)$ {
			try_files /does_not_exists @php;
		}
		location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|webp|woff|woff2)$ {
			expires 24h;
		}
	}
	
	location @php {
		include /etc/nginx/vhosts-resources/213.139.209.81/dynamic/*.conf;
		fastcgi_index index.php;
		fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@213.139.209.81";
		fastcgi_pass unix:/var/www/php-fpm/1.sock;
		fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
		try_files $uri =404;
		include fastcgi_params;
	}
	
	location @fallback {
        fastcgi_pass unix:/var/www/php-fpm/1.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }
}

Если закомментировать строки
location / {
		location ~ [^/]\.ph(p\d*|tml)$ {
			try_files /does_not_exists @php;
		}
		location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|webp|woff|woff2)$ {
			expires 24h;
		}
	}
То главная перестает открываться и скачивается пустой файл при открытии страницы

Все остальное сделал как в статье modx.pro/lessons/23730, однако так и не запускается

Вячеслав Варов
08 мая 2024, 12:53
modx.pro
252
0

Комментарии: 1

Вячеслав Варов
08 мая 2024, 13:36
1
0
server {
	server_name 213.139.209.81 www.213.139.209.81;
    return 301 https://213.139.209.81$request_uri;
	charset off;
	index index.php index.html;
	disable_symlinks if_not_owner from=$root_path;
	include /etc/nginx/vhosts-includes/*.conf;
	include /etc/nginx/vhosts-resources/213.139.209.81/*.conf;
	access_log /var/www/httpd-logs/213.139.209.81.access.log;
	error_log /var/www/httpd-logs/213.139.209.81.error.log notice;
	ssi on;
	set $root_path /var/www/www-root/data/www/213.139.209.81;
	root $root_path;
	gzip on;
	gzip_comp_level 5;
	gzip_disable "msie6";
	gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
	
	location @modx-rewrite {
        rewrite ^/(.*)$ /index.php?q=$1&$args last;
    }
	
	location / {
		try_files $uri $uri/ @modx-rewrite;
		location ~ [^/]\.ph(p\d*|tml)$ {
			try_files /does_not_exists @php;
		}
		location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|webp|woff|woff2)$ {
			expires 24h;
		}
	}
	location @php {
		include /etc/nginx/vhosts-resources/213.139.209.81/dynamic/*.conf;
		fastcgi_index index.php;
		fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@213.139.209.81";
		fastcgi_pass unix:/var/www/php-fpm/1.sock;
		fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
		try_files $uri =404;
		include fastcgi_params;
	}
	listen 213.139.209.81:80;
}
server {
	server_name 213.139.209.81 www.213.139.209.81;
	ssl_certificate "/var/www/httpd-cert/www-root/213.139.209.81_le1.crt";
	ssl_certificate_key "/var/www/httpd-cert/www-root/213.139.209.81_le1.key";
	ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
	ssl_prefer_server_ciphers on;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
	ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
	charset off;
	index index.php index.html;
	disable_symlinks if_not_owner from=$root_path;
	include /etc/nginx/vhosts-includes/*.conf;
	include /etc/nginx/vhosts-resources/213.139.209.81/*.conf;
	access_log /var/www/httpd-logs/213.139.209.81.access.log;
	error_log /var/www/httpd-logs/213.139.209.81.error.log notice;
	ssi on;
	set $root_path /var/www/www-root/data/www/213.139.209.81;
	root $root_path;
	gzip on;
	gzip_comp_level 5;
	gzip_disable "msie6";
	gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
	
    
    location @modx-rewrite {
        rewrite ^/(.*)$ /index.php?q=$1&$args last;
    }
	
	location / {
		location ~ [^/]\.ph(p\d*|tml)$ {
			try_files /does_not_exists @php;
		}
		location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|webp|woff|woff2)$ {
			expires 24h;
		}
		try_files $uri $uri/ @modx-rewrite;
	}
	
	location @php {
		include /etc/nginx/vhosts-resources/213.139.209.81/dynamic/*.conf;
		fastcgi_index index.php;
		fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@213.139.209.81";
		fastcgi_pass unix:/var/www/php-fpm/1.sock;
		fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
		try_files $uri =404;
		include fastcgi_params;
	}
	
	listen 213.139.209.81:443 ssl;
}
Получилось так, может кому полезно будет)
    Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
    1