<div dir="ltr">On Mon, Jul 28, 2014 at 5:35 PM, lorenanicole <span dir="ltr"><<a href="mailto:nginx-forum@nginx.us" target="_blank">nginx-forum@nginx.us</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
The concern here is if there is a way to redirect the rewritten uri without<br>
having to break out and start processing the request again (argument last)?<br>
Additionally, is the setting of zone's using the IP address as the key the<br>
proper way to control these different rate limiting and burst thresholds?<br></blockquote><div><br><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
I am no expert, but in my own eyes, I would have avoided using:<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">1°) A series of 'if' which behavior might be clumsy<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
2°) Redirections which kind of 'cut the flow'<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">What I would have done:<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
1°) Defining all the log_format stuff at the http level: the sooner, the better<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"><br>2°) Replacing the if series with a map (also in http) like the following:<br>
</div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">map $http_user_agent $language {<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> Java/* java<br>...<br></div>
<div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> "" etc<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> default none<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
}<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">3°) Using the output of the first map as the input of two others to define zone and burst amount, like:<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
map $language $zone {<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> java one<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">}<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
<br>map $language $burst {<br> java 140<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">}<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">4°) Processing all the requests in the default location :<br>
</div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">location / {<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> root html;<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
index index.html;<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> if($language != none) {<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> limit_req zone=$zone burst=$burst;<br>
<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> access_log /var/log/nginx/access.log $language;<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> proxy_pass <a href="https://example.com">https://example.com</a>;<br>
</div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> }<br><br>...<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">}<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
All that is not error-proof, coming straight outta my mind with no testing... but you get the general idea.<br></div><div><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div>
</div></div></div></div></div>