我不断收到以下错误:
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
- 但显然我确实需要这个功能。
如果我启用LogLevel debug rewrite: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"]
答案1
该错误很可能是由于 URL 格式错误而发生的 - 即使它只报告了一个模糊的Bad Request
错误。
可能是失踪了/
......
RewriteRule ^(.*)$ /index.php [L,QSA]
代替
RewriteRule ^(.*)$ index.php [L,QSA]