HTTP 400 483 с Apache ProxyPassMatch и RewriteCond

Я все время получаю сообщение об ошибке:

apache_1_da0b6d97082f | 172.24.0.1 - - [16/Sep/2019:15:58:52 +0000] "GET /logi HTTP/1.1" 400 483 "-" "curl/7.64.0"

Но я не знаю почему? Похоже, что запрос не проходит через сокет php-fpm.

ServerName mainapp.local

<VirtualHost *:80>
    ServerName mainapp.local

    DocumentRoot /var/www/html/public/
    CustomLog /dev/stdout combined
    LogLevel debug

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [L,QSA]

    ProxyPreserveHost On
    ProxyPassMatch "^/(.*\.php(/.*)?)$"           "unix:/this/path/does/not/matter.sock|fcgi://localhost/var/www/html/public"

    <Directory "/var/www/html">
        Options +Indexes +FollowSymLinks +IncludesNOEXEC -MultiViews
        AllowOverride All
        Require all granted
        DirectoryIndex index.php
    </Directory>

</VirtualHost>

Он работает правильно (HTTP 200) без директив Rewrite , но, очевидно, мне нужна эта функция.


Если я enable Перезапись отладки LogLevel: trace8 :

... mod_rewrite.c(483): [client 172.24.0.1:50934] 172.24.0.1 - - [localhost/sid#7f20f4ad15e8][rid#7f20f40e50a0/initial] init rewrite engine with requested uri /test
... mod_rewrite.c(483): [client 172.24.0.1:50934] 172.24.0.1 - - [localhost/sid#7f20f4ad15e8][rid#7f20f40e50a0/initial] applying pattern '(.+)' to uri '/test'
... mod_rewrite.c(483): [client 172.24.0.1:50934] 172.24.0.1 - - [localhost/sid#7f20f4ad15e8][rid#7f20f40e50a0/initial] RewriteCond: input='/test' pattern='!-f' => matched
... mod_rewrite.c(483): [client 172.24.0.1:50934] 172.24.0.1 - - [localhost/sid#7f20f4ad15e8][rid#7f20f40e50a0/initial] RewriteCond: input='/test' pattern='!-d' => matched
... mod_rewrite.c(483): [client 172.24.0.1:50934] 172.24.0.1 - - [localhost/sid#7f20f4ad15e8][rid#7f20f40e50a0/initial] rewrite '/test' -> 'index.php?p=/test'
... mod_rewrite.c(483): [client 172.24.0.1:50934] 172.24.0.1 - - [localhost/sid#7f20f4ad15e8][rid#7f20f40e50a0/initial] split uri=index.php?p=/test -> uri=index.php, args=p=/test
... mod_rewrite.c(483): [client 172.24.0.1:50934] 172.24.0.1 - - [localhost/sid#7f20f4ad15e8][rid#7f20f40e50a0/initial] local path result: index.php


Вот Dockerfile , который я использовал для создания образа:

# FROM debian:buster

FROM debian@sha256:903779f30a7ee46937bfb21406f125d5fdace4178074e1cc71c49039ebf7f48f

ARG DEBIAN_FRONTEND=noninteractive

RUN apt update
RUN apt install -y apache2 libapache2-mod-fcgid

COPY ./mainapp_vhost.conf /etc/apache2/sites-available/000-default.conf

RUN a2enmod actions proxy proxy_ajp proxy_http proxy_fcgi rewrite
RUN mkdir /var/lib/php-fcgi

RUN chmod 644 /var/log/apache2

ENV APACHE_UID 33
ENV APACHE_GID 33

RUN ln -sf /dev/stdout /var/log/apache2/access.log
RUN ln -sf /dev/stderr /var/log/apache2/error.log

RUN mkdir /var/www/html/public

RUN apachectl configtest

ENTRYPOINT ["/usr/sbin/apache2ctl"]
CMD ["-D", "FOREGROUND"]
0
задан 16 September 2019 в 20:59
1 ответ

Скорее всего, ошибка возникает из-за неправильного URL-адреса, хотя в нем сообщается только расплывчатая ошибка Плохой запрос .


Вероятно, это отсутствующий / ....

RewriteRule ^(.*)$ /index.php [L,QSA]

Вместо

RewriteRule ^(.*)$ index.php [L,QSA]

Почему мое правило перезаписи приводит к "400: неверный запрос"?

0
ответ дан 5 December 2019 в 00:48

Теги

Похожие вопросы