<?xml version="1.0" encoding="utf-8"?>
<s1 title="HelpOnConfiguration/SurgeProtection"><p></p>
<s2 id="Surge Protection" title="Surge Protection">
<p><p>Contents</p>
<ol><li>
<link anchor="S">Surge Protection</link><ol><li>
<link anchor="W">What can we do?</link></li>
<li>
<link anchor="C">Configuration</link></li>
<li>
<link anchor="H">Hints</link><ol><li>
<link anchor="B">Big proxy or firewall</link></li>
<li>
<link anchor="D">Disabling surge protection</link></li>
</ol>
</li>
</ol>
</li>
</ol>
<p> Especially on an internet wiki sometimes the cpu and disk load gets quite high because the wiki has to process many requests. A high load makes the wiki slow or unusable for its legitimate users. </p>
<p>This is caused by: </p>
<ul><li>some bad guys (spammers, vandals, ...) trying to put spam or trash on your pages </li>
<li><p>some less-bad guys (people just <em>mirroring</em> the wiki, without thinking about the load and the lots of useless requests and high traffic they cause) </p>
</li>
<li>some bots, indexing the wiki content for some search engine </li>
</ul>
<p></p>
<s3 id="What can we do?" title="What can we do?">
<p><jump href="/wiki/MoinMoin">MoinMoin</jump> tracks requests by user name (if logged in) or IP address (if not logged in). </p>
<p>If the request count goes beyond some configured limit in some configured time interval, it will start to warn you (you will see a surge protection warning message instead of the expected wiki output). If you see this warning, just read it and do what it tells. </p>
<p>You should stop doing those requests for a minute in that case (just read the stuff you already got, drink some water, ...). You will have no problems if you continue a while later (just slow down a bit, so you won&apos;t go beyond the limit again). </p>
<p>If you don&apos;t pause and ignore the warnings and the requests don&apos;t stop hammering the wiki server, the wiki will think you are doing something nasty and will lock you out for some configurable amount of time. </p>
<p></p>
</s3>
<s3 id="Configuration" title="Configuration">
<p>Configuration is done as usual: in your wikiconfig. These are the built-in default values: </p>
<p></p>
<codearea id="2ffff3464db85a7b49dda0b1dc097095ad118ca9"><codeline>    <codetoken type="ID">surge_action_limits</codetoken = {</codeline<codeline>        <codetoken type="Comment"># allow max. &lt;count&gt; &lt;action&gt; requests per &lt;dt&gt; secs</codetoken</codeline<codeline>        <codetoken type="Comment"># Format:</codetoken</codeline<codeline>        <codetoken type="Comment"># action:     (count,  dt)</codetoken</codeline<codeline>        <codetoken type="String">&apos;</codetoken<codetoken type="String">all</codetoken<codetoken type="String">&apos;</codetoken:           (<codetoken type="Number">30</codetoken,  <codetoken type="Number">30</codetoken), <codetoken type="Comment"># all requests (except cache/AttachFile action) count for this limit</codetoken</codeline<codeline>        <codetoken type="String">&apos;</codetoken<codetoken type="String">default</codetoken<codetoken type="String">&apos;</codetoken:       (<codetoken type="Number">30</codetoken,  <codetoken type="Number">60</codetoken), <codetoken type="Comment"># default limit for actions without a specific limit</codetoken</codeline<codeline>        <codetoken type="String">&apos;</codetoken<codetoken type="String">show</codetoken<codetoken type="String">&apos;</codetoken:          (<codetoken type="Number">30</codetoken,  <codetoken type="Number">60</codetoken),</codeline<codeline>        <codetoken type="String">&apos;</codetoken<codetoken type="String">recall</codetoken<codetoken type="String">&apos;</codetoken:        (<codetoken type="Number">10</codetoken, <codetoken type="Number">120</codetoken),</codeline<codeline>        <codetoken type="String">&apos;</codetoken<codetoken type="String">raw</codetoken<codetoken type="String">&apos;</codetoken:           (<codetoken type="Number">20</codetoken,  <codetoken type="Number">40</codetoken), <codetoken type="Comment"># some people use this for css</codetoken</codeline<codeline>        <codetoken type="String">&apos;</codetoken<codetoken type="String">diff</codetoken<codetoken type="String">&apos;</codetoken:          (<codetoken type="Number">30</codetoken,  <codetoken type="Number">60</codetoken),</codeline<codeline>        <codetoken type="String">&apos;</codetoken<codetoken type="String">fullsearch</codetoken<codetoken type="String">&apos;</codetoken:    (<codetoken type="Number">10</codetoken, <codetoken type="Number">120</codetoken),</codeline<codeline>        <codetoken type="String">&apos;</codetoken<codetoken type="String">edit</codetoken<codetoken type="String">&apos;</codetoken:          (<codetoken type="Number">30</codetoken, <codetoken type="Number">300</codetoken), <codetoken type="Comment"># can be lowered after making preview different from edit</codetoken</codeline<codeline>        <codetoken type="String">&apos;</codetoken<codetoken type="String">rss_rc</codetoken<codetoken type="String">&apos;</codetoken:         (<codetoken type="Number">1</codetoken,  <codetoken type="Number">60</codetoken),</codeline<codeline></codeline<codeline>        <codetoken type="Comment"># The following actions are often used for images - to avoid pages with lots of images</codetoken</codeline<codeline>        <codetoken type="Comment"># (like photo galleries) triggering surge protection, we assign rather high limits:</codetoken</codeline<codeline>        <codetoken type="String">&apos;</codetoken<codetoken type="String">AttachFile</codetoken<codetoken type="String">&apos;</codetoken:   (<codetoken type="Number">300</codetoken,  <codetoken type="Number">30</codetoken),</codeline<codeline>        <codetoken type="String">&apos;</codetoken<codetoken type="String">cache</codetoken<codetoken type="String">&apos;</codetoken:        (<codetoken type="Number">600</codetoken,  <codetoken type="Number">30</codetoken), <codetoken type="Comment"># cache action is very cheap/efficient</codetoken</codeline<codeline>    }</codeline<codeline>    <codetoken type="ID">surge_lockout_time</codetoken = <codetoken type="Number">3600</codetoken       <codetoken type="Comment"># secs you get locked out when you ignore warnings</codetoken</codeline</codearea<p> </p>
<p></p>
</s3>
<s3 id="Hints" title="Hints">
<p></p>
<s4 id="Big proxy or firewall" title="Big proxy or firewall">
<p>If you happen to be behind a big proxy or firewall (china? big company network?) you might get trouble with surge protection because all requests come from a single IP address, looking like a really nasty user or bot. </p>
<p>But you can easily work around that by just logging in, so it really counts <em>your</em> requests (it uses your name in that case to count requests, not your proxy/firewall IP). </p>
<p>You will also have no problem, if your proxy uses the &apos;x-forwarded-for&apos; header with your real IP. </p>
<p></p>
</s4>
<s4 id="Disabling surge protection" title="Disabling surge protection">
<p>(!) It is not advised to do that. If it triggers too fast, adjust the limits to your needs. Even in an intranet wiki, it is no good if a single user can make the wiki unusable for everybody by firing up some leech tool at it. </p>
<p>If you want to do it nevertheless: </p>
<p></p>
<source><![CDATA[    surge_action_limits = None # disable surge protection]]></source></s4></s3></s2></s1>