PHP脚本在无限循环中生成对自身的请求

时间:2015-06-12 19:37:16

标签: php mysql .htaccess magento session

我甚至不确定我是否正确描述了这个问题。我想我想知道的主要内容是如何在代码中跟踪这些请求的来源。

问题出现之前,我已经解决了#34;它通过向服务器本身的IP添加deny.htaccess

这个问题突然再次发生,没有明显的原因。我的.htaccess设置失去了神奇的保护能力。代码中没有进行任何更改。在重新发生的时候,我更改了配置设置以添加cookie域。我尝试将其更改为空白,我尝试删除所有会话文件(和Magento缓存)。如果会话设置导致重复,那应该已经修复但是没有。

唯一能够修复"它正在关闭Magento设置以进行Web服务器重写" clean"在.htacces中注释掉这一行的网址:

RewriteRule .* index.php [L]

网站现在"工作",丑陋的网址,神秘地,令人难以置信的降级性能。页面加载时间为10-20秒,用于取1-2。 PHP和MySQL现在似乎正常运行。

但是在问题发生后的原始设置中,我在命令行的top中看到了一堆PHP实例。 MySQL SHOW PROCESSLIST显示出越来越多的睡眠过程。我的Magento网站session文件夹不断添加新会话(每秒大约1个新会话,即使我的客户端浏览器IP地址是此测试期间htaccess允许的唯一一个)。 从客户端的浏览器,大多数请求超时,很少页面在很长时间后加载(10+分钟 - PHP max_execution_time很长,以允许完成长导入/导出过程)。

静态index.php只是回声"它起作用"加载没有任何奇怪的错误。

我不知道问题是什么。是恶意代码吗?会话处理有问题吗?它甚至可能与DNS有关吗?如果我能追踪“僵尸”的来源,我可以在解决问题方面取得进展。以某种方式请求。

编辑:这是我完整的.htaccess文件,有些东西已经编辑(我更改了IP地址)

############################################
## default index file

    DirectoryIndex index.php

<IfModule mod_php5.c>

############################################
## adjust memory limit

#    php_value memory_limit 512M
 #   php_value max_execution_time 10
    php_value max_input_time 18000

############################################
## disable magic quotes for php request vars

    php_flag magic_quotes_gpc off

############################################
## disable automatic session start
## before autoload was initialized


    php_flag session.auto_start off

############################################
## enable resulting html compression

    php_flag zlib.output_compression on

###########################################
# disable user agent verification to not break multiple image upload

    php_flag suhosin.session.cryptua off

###########################################
# turn off compatibility with PHP4 when dealing with objects

    php_flag zend.ze1_compatibility_mode Off

</IfModule>

<IfModule mod_security.c>
###########################################
# disable POST processing to not break multiple image upload

    SecFilterEngine Off
    SecFilterScanPOST Off
</IfModule>

<IfModule mod_deflate.c>

############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip

# Insert filter
SetOutputFilter DEFLATE

# Netscape 4.x has some problemsÂ~E
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# DonÂ~Rt compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies donÂ~Rt deliver the wrong content
Header append Vary User-Agent env=!dont-vary

# enable resulting html compression
#php_flag zlib.output_compression on

</IfModule>

<IfModule mod_ssl.c>

############################################
## make HTTPS env vars available for CGI mode

    SSLOptions StdEnvVars

</IfModule>

<IfModule mod_rewrite.c>

############################################
## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on


############################################
## you can put here your magento root folder
## path relative to web root

# if site is at raw ip/user url like http://111.22.33.44/~users_folder/
#   RewriteBase /~users_folder/
        RewriteBase /

############################################
## workaround for HTTP authorization
## in CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## always send 404 on missing files in these folders

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

    RewriteRule .* index.php [L]

</IfModule>


############################################
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead

    AddDefaultCharset Off
    #AddDefaultCharset UTF-8

<IfModule mod_expires.c>

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
        ExpiresActive On
        ExpiresDefault "access plus 1 year"
    #ExpiresDefault "access plus 1 year"

</IfModule>

############################################
## By default allow all access

    Order allow,deny
    Allow from all
        #try denying own ip. it seems like it is sending the requests!
        #this server ip e.g. 111.22.33.44
        # this hack "fixed" the problem a long time ago.
        Deny from 111.22.33.44

#       Order deny,allow
#       Deny from all
#       Allow from [particular IP for testing]

<FilesMatch "\.(?:inc|ini|txt|tar|gz|sql|sh|zip|htm|html|log)$|apc.php">
        Order allow,deny
        Deny from all
</FilesMatch>


############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags

    FileETag none

Options All -Indexes

# 4 Weeks
<FilesMatch "\.(html|htm|phtml)$">
Header set Cache-Control "max-age=2419200, must-revalidate"
</FilesMatch>
<FilesMatch "\.(js|css|swf)$">
        Header set Cache-Control "max-age=2419200"
</FilesMatch>
<FilesMatch "\.(jpg|jpeg|png|gif|swf|PNG|JPEG|GIF|SWF|JPG)$">
        Header set Cache-Control "max-age=2419200, public"
</FilesMatch>
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
# compress text, HTML, JavaScript, CSS, and XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/phtml
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/GIF "access plus 1 month"
ExpiresByType image/PNG "access plus 1 month"
ExpiresByType image/JPG "access plus 1 month"
ExpiresByType image/JPEG "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>

0 个答案:

没有答案