.htaccess - 由于 timthumb 文件,Apache2 正在循环
问题描述
我有一个带有以下.htaccess
文件的 apache2 服务器设置/
<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>
RewriteEngine on
#REDIRE HTTPS
#RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
#REDIR WWW
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L,QSA]
#resize photos
RewriteRule ^photos_(\d*?)x(\d*?)\/(.*)(.jpg|.jpeg|.png|.gif)$ %{ENV:REWRITEBASE}/lib/timthumb/timthumb.php?src=/photos/$3$4&w=$1&h=$2&zc=1 [NC,L]
#RewriteRule ^photos_ext_(\d*?)x(\d*?)\/http([s]*).*?\/(.*)(.jpg|.jpeg|.png|.gif)$ %{ENV:REWRITEBASE}/lib/timthumb/timthumb.php?src=http$3://$4$5&w=$1&h=$2&zc=1 [NC,L]
#RewriteRule ^photos_ext_(\d*?)\/http([s]*).*?\/(.*)(.jpg|.jpeg|.png|.gif)$ %{ENV:REWRITEBASE}/lib/timthumb/timthumb.php?src=http$2://$3$4&w=$1&h=$2&zc=1 [NC,L]
RewriteRule ^photos_(\d*?)\/(.*)(.jpg|.jpeg|.png|.gif)$ %{ENV:REWRITEBASE}/lib/timthumb/timthumb.php?src=/photos/$2$3&w=$1&h=$1&zc=1 [NC,L]
RewriteRule ^visuels_(\d*?)\/(.*)(.jpg|.jpeg|.png|.gif)$ %{ENV:REWRITEBASE}/lib/timthumb/timthumb.php?src=/visuels/$2$3&w=$1&h=$1&zc=1 [NC,L]
#js traductions
RewriteRule ^themes\/.*?\/js\/traduction.js$ %{ENV:REWRITEBASE}/traductionjs [NC,L,R=301]
# Dispatcher
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
</IfModule>
<IfModule mod_php5.c>
php_value short_open_tag 1
</IfModule>
#<FilesMatch "\.(js)$">
#Header set Access-Control-Allow-Origin "*"
#</FilesMatch>
#optimisations
Options -Indexes
ServerSignature Off
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/x-javascript font/ttf application/x-font-ttf font/otf application/x-font-otf font/opentype image/svg+xml application/x-httpd-php
#Pour les navigateurs incompatibles
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
#les proxies doivent donner le bon contenu
Header append Vary User-Agent env=!dont-vary
<IfModule mod_headers.c>
Header always set X-FRAME-OPTIONS "SAMEORIGIN"
Header always set X-XSS-Protection "1; mode=block"
Header always set X-Content-Type-Options "nosniff"
</IfModule>
<ifModule mod_php5.c>
php_value zlib.output_compression 16386
php_value zlib.output_compression_level 5
</ifModule>
FileETag none
<IfModule mod_headers.c>
Header unset ETag
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 week"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 week"
ExpiresByType application/x-shockwave-flash "access plus 1 week"
ExpiresByType text/css "access plus 0 seconds"
ExpiresByType text/javascript "access plus 0 seconds"
ExpiresByType application/x-javascript "access plus 0 seconds"
</IfModule>
#No cache for DEV mode
<filesMatch "\.(js|css)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</filesMatch>
和以下代理传入000-default.conf
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass /wallet http://wallet/
ProxyPassReverse /wallet http://wallet/
ServerName localhost
</VirtualHost>
代理 docker 应用程序从 /wallet 到http://wallet。当我现在访问一个看起来像这样的 URL 时,http://localhost/series/adventure/adult/helloworld2
我会在一段时间后收到以下错误:
www_1 | [Thu Nov 01 16:02:49.226185 2018] [mpm_prefork:error]
[pid 1] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
www_1 | localhost:80 127.0.0.1 - - [01/Nov/2018:16:02:47 +0000] "GET /lib/timthumb/timthumb.php?src=/photos/logo-default.jpg&w=300&h=300&zc=2 HTTP/1.0" 400 811 "-" "-"
www_1 | localhost:80 127.0.0.1 - - [01/Nov/2018:16:02:47 +0000] "GET /lib/timthumb/timthumb.php?src=/photos/logo-default.jpg&w=300&h=300&zc=2 HTTP/1.0" 400 811 "-" "-"
www_1 | localhost:80 127.0.0.1 - - [01/Nov/2018:16:02:47 +0000] "GET /lib/timthumb/timthumb.php?src=/photos/logo-default.jpg&w=300&h=300&zc=2 HTTP/1.0" 400 811 "-" "-"
www_1 | localhost:80 127.0.0.1 - - [01/Nov/2018:16:02:47 +0000] "GET /lib/timthumb/timthumb.php?src=/photos/logo-default.jpg&w=300&h=300&zc=2 HTTP/1.0" 400 811 "-" "-"
this goes on forever
之后,apache2 服务器无法访问,我需要重新启动它。我在网上没有找到任何东西,但已经尝试设置 mpm_event.conf 和其他参数。从根本上说,我认为我的配置中有一个循环。我不知道在哪里。我可以发布 docker 文件,但这没什么特别的。
启动 php 脚本时会调用两行代码:
define ('NOT_FOUND_IMAGE',
"http://".$_SERVER["HTTP_HOST"].'/lib/timthumb/timthumb.php?src=/photos/'.$config["image_default"].'&w='.$_GET["w"].'&h='.$_GET["h"].'&zc=2');
define ('ERROR_IMAGE', "http://".$_SERVER["HTTP_HOST"].'/lib/timthumb/timthumb.php?src=/photos/'.$config["image_default"].'&w='.$_GET["w"].'&h='.$_GET["h"].'&zc=2');
解决方案
推荐阅读
- png - 来自 csv 的 Photoshop 数据集和变量限制为 99 个?
- asp.net - Azure 中 IIS/ASP.NET 的等效用户帐户是什么
- mysql - SQL 循环除了手动执行之外什么都不做。它的工作
- c - C语言中使用"和'的区别
- scipy-optimize-minimize - 如何让最小化函数理解我的神经网络模型?
- python - 如何检查用户是否在角色列表中具有特定角色?(discord.py)
- ns-3 - 将 ns3 与 ns3-bgp 一起使用
- mobile - Microsoft Teams 自定义应用程序无法在移动设备上运行
- java - 在抽屉菜单中的片段之间切换什么都不做
- scikit-learn - python 3.8错误与交叉验证实现