Уважаемые пользователи!
C 7 ноября 2020 года phpBB Group прекратила выпуск обновлений и завершила дальнейшее развитие phpBB версии 3.2.
С 1 августа 2024 года phpBB Group прекращает поддержку phpBB 3.2 на официальном сайте.
Сайт официальной русской поддержки phpBB Guru продолжит поддержку phpBB 3.2 до 31 декабря 2024 года.
С учетом этого, настоятельно рекомендуется обновить конференции до версии 3.3.

Вилы: либо нет URL-rewriting'а, либо главную не открыть без index.php

Проблемы с установкой или работой phpBB 3.3.x? Получите помощь здесь!
Правила форума
Местная Конституция | Шаблон запроса | Документация (phpBB3) | Мини [FAQ] по phpBB 3.1.x/3.2.x | FAQ | Как задавать вопросы | Как устанавливать расширения

Ваш вопрос может быть удален без объяснения причин, если на него есть ответы по приведённым ссылкам (а вы рискуете получить предупреждение ;) ).
mr_ppc
phpBB 1.0.0
Сообщения: 1
Стаж: 3 года 9 месяцев

Вилы: либо нет URL-rewriting'а, либо главную не открыть без index.php

Сообщение mr_ppc »

Здравствуйте!

Прошу по возможности помочь. Связка: phpbb 3.3 + nginx + php-fpm + VestaCP. Есть два шаблона весты:

1.stpl:

Код: Выделить всё

server {
    listen      %ip%:%web_ssl_port% http2;
    server_name %domain_idn% %alias_idn%;
    root        %docroot%;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;
    if ($host != "%domain%") {
            return 301 https://%domain%$request_uri;
        }
ssl on;
 ssl_certificate %ssl_pem%;
 ssl_certificate_key %ssl_key%;


        location / {
            # phpBB uses index.htm
            index index.php index.html index.htm;
            try_files $uri $uri/ @rewriteapp;
        }

        location @rewriteapp {
            rewrite ^(.*)$ /app.php/$1 last;
        }

        # Deny access to internal phpbb files.
        location ~ /(config\.php|common\.php|cache|files|images/avatars/upload|includes|(?<!ext/)phpbb|store|vendor) {
            deny all;
            # deny was ignored before 0.8.40 for connections over IPv6.
            # Use internal directive to prohibit access on older versions.
            internal;
            return 404;
        }

        # Pass the php scripts to fastcgi server specified in upstream declaration.
        location ~ \.php(/|$) {
            # Unmodified fastcgi_params from nginx distribution.
            include fastcgi_params;
            # Necessary for php.
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            try_files $uri $uri/ /app.php$is_args$args;
            fastcgi_index   index.php;
            fastcgi_pass %backend_lsnr%; # - должно быть то же самое, что и в секции location / дефолтного шаблона
          }


        # Correctly pass scripts for installer
        location /install/ {
            # phpBB uses index.htm
            try_files $uri $uri/ @rewrite_installapp;

            # Pass the php scripts to fastcgi server specified in upstream declaration.
            location ~ \.php(/|$) {
                # Unmodified fastcgi_params from nginx distribution.
                include fastcgi_params;
                # Necessary for php.
                fastcgi_split_path_info ^(.+\.php)(/.*)$;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
                fastcgi_param DOCUMENT_ROOT $realpath_root;
                try_files $uri $uri/ /install/app.php$is_args$args;
                fastcgi_pass %backend_lsnr%; # - должно быть то же самое, что и в секции location / дефолтного шаблона
            }
        }

        location @rewrite_installapp {
                  rewrite ^(.*)$ /install/app.php/$1 last;
        }


         # Deny access to version control system directories.
        location ~ /\.svn|/\.git {
            deny all;
            internal;
        }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   %home%/%user%/web/%domain%/stats/;
#        include %home%/%user%/conf/web/%domain%.auth
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     %home%/%user%/conf/web/nginx.%domain_idn%.conf*;
}

и 2.stpl:

Код: Выделить всё

server {
 listen %ip%:%web_ssl_port% http2;
 server_name %domain_idn% %alias_idn%;
 root %sdocroot%;
 index index.php index.html index.htm;
 access_log /var/log/nginx/domains/%domain%.log combined;
 access_log /var/log/nginx/domains/%domain%.bytes bytes;
 error_log /var/log/nginx/domains/%domain%.error.log error;
 if ($host != "%domain%") {
            return 301 https://%domain%$request_uri;
        }

ssl on;
 ssl_certificate %ssl_pem%;
 ssl_certificate_key %ssl_key%;

location / {

location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
 expires max;
 }

location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri $uri/ /app.php$is_args$args;
# if (!-f $document_root$fastcgi_script_name) {
# return 404;
#}

fastcgi_pass %backend_lsnr%;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
 }
 }

location ~* "/\.(htaccess|htpasswd)$" {
 deny all;
 return 404;
 }


include %home%/%user%/conf/web/snginx.%domain%.conf*;
}

C 1.stpl нормально работает URL-rewriting, но главная страница форума открывается только с приставкой «index.php» (иначе открывается интерфейс phpbb и информация, что запрашиваемая страница не найдена). С шаблоном 2.stpl rewriting не работает, но зато главная страница открывается как с index.php, так и без него.

Желаемый результат: чтобы был и URL-rewriting, и главную можно было открыть без index.php. Ну и чтобы решение было как можно менее костыльным)

Полагаю, дело в каком-то незначительном куске кода в шаблоне 1.stpl, но сам не могу допереть.

Адрес форума: forum.aidazanami.ru.

Заранее благодарен за потраченное время!
noob_dev
phpBB 1.2.0
Сообщения: 13
Стаж: 3 года 9 месяцев

Re: Вилы: либо нет URL-rewriting'а, либо главную не открыть без index.php

Сообщение noob_dev »

Перед "ssl on;"

Код: Выделить всё

if ($request_uri ~* "^(.*/)index\.php$") {
    return 301 $1;
}
Либо:

Код: Выделить всё

if ($request_uri ~ ^/index.php) {
   rewrite ^.*$ / permanent;
}
Пробовали?

Вернуться в «Поддержка phpBB 3.3.x»