Guys,
I have a proxy which runs at http://xs.to . It caches
http://f0.ultraxs.com . I need it to rewrite to a JPG 10% of the time.
I did this with upstream backend, but the issue was that the disk i/o
really shot up doing that.
Is there a good clean way to run an if statement and rewrite 10% of the
requests ?
Khalid
Posted at Nginx Forum:
Guys, I have a proxy which runs at http://xs.to. It caches http://f0.ultraxs.com. I need it to rewrite to a JPG 10% of the time. I did this with upstream backend, but the issue was that the disk i/o really shot up doing that. Is there a good clean...
kshaikh
February 2, 2010, 11:05am
2
kshaikh wrote:
I have a proxy which runs at http://xs.to . It caches http://f0.ultraxs.com . I need it to rewrite to a JPG 10% of the time.
…
Is there a good clean way to run an if statement and rewrite 10% of the requests ?
This can be done via embedded perl
example:
perl_set $random_rewrite_to ’
sub { rand > 0.1 ? “url_90_percent” : “url_10_percent” }
';
server {
…
location /some_location {
rewrite ^ $random_rewrite_to;
}
}
–
Anton Y.