<div class="gmail_quote"><div dir="ltr">On Wed, Apr 4, 2018, 22:18 Alex Ivanov <<a href="mailto:gnidorah@ya.ru">gnidorah@ya.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi.<br>
I want to use systemd as fastcgi spawner for gitweb + nginx.<br>
The traffic is low and number of users is limited + traversal bots. For that reason I've decided to use following mimimal services<br>
<br>
gitweb.socket:<br>
[Unit]<br>
Description=GitWeb Socket<br>
<br>
[Socket]<br>
ListenStream=/run/gitweb.sock<br>
Accept=false<br>
<br>
[Install]<br>
WantedBy=sockets.target<br>
<br>
gitweb.service:<br>
[Unit]<br>
Description=GitWeb Service<br>
<br>
[Service]<br>
Type=simple<br>
ExecStart=/path/to/gitweb.cgi --fcgi<br>
StandardInput=socket<br>
<br>
However this scheme is not resistant to simple DDOS.<br>
E.g. traversal bots often kill the service by opening non existing path (e.g <a href="http://host/?p=repo;a=blob;f=nonexisting/path;hb=HEAD" rel="noreferrer" target="_blank">http://host/?p=repo;a=blob;f=nonexisting/path;hb=HEAD</a> showing in browser 404 - Cannot find file) many times consecutively, which leads to<br>
Apr 03 21:32:10 host systemd[1]: gitweb.service: Start request repeated too quickly.<br>
Apr 03 21:32:10 host systemd[1]: gitweb.service: Failed with result 'start-limit-hit'.<br>
Apr 03 21:32:10 host systemd[1]: Failed to start GitWeb service.<br>
in journal and 502 Bad Gateway in browser.<br>
<br>
Could someone please show me how to correct this issue?<br></blockquote></div><div><br></div><div>I don't quite understand how gitweb.cgi is designed and how it's supposed to behave here.</div><div><br></div><div>You use Accept=no, which implies that gitweb.cgi should start *once* and keep accepting connections in a loop forever. So why does it keep exiting and restarting *at all*? Why does a simple 404 make it exit the whole event loop?</div><div><br></div><div>If it doesn't accept connections on its own, but needs to be passed in an already-accepted connection, that'd be Accept=yes... And I'm not sure if systemd activation like this is suitable for very high request rates.</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><p dir="ltr">Mantas Mikulėnas <<a href="mailto:grawity@gmail.com">grawity@gmail.com</a>><br>
Sent from my phone</p>
</div></div>