S
S
ShadowHacker2012-04-13 05:12:02
Nginx
ShadowHacker, 2012-04-13 05:12:02

Serving a random file at a specific URL

Is it possible to configure nginx in such a way that one random static file from a given set is returned at a certain url for each request?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Stdit, 2012-04-13
@Stdit

wiki.nginx.org/HttpRandomIndexModule won't work?

R
rPman, 2012-04-13
@rPman

Don't you want 'crutches'?

<?php header('Location: '.rand(1000000,9999999)); ?>
Indeed, in this case, the files for clients will remain static, with all the goodies of caching, etc.
I checked that browsers open all the necessary resources without any problems, no matter how many redirects were made to receive them.

V
Vitaly Peretyatko, 2012-04-13
@viperet

It is better to rebuild nginx "for yourself", it's easy. Once I solved such a problem through random_index, and then I added the set_random var min max function to the set_misc module; which is much more convenient to give a random file by URL. By the way, I used this for rotating static pre-saved html blocks.
Now we are thinking of changing the rotation policy (because out of 5 blocks, randomly, it often shows the same ones in a row). Made the command set_rotate var from to; and sent a pull request to the developer of the set_misc module. With this command it is easy to rotate blocks in order, the value of the last shown block can be stored in Cookies

I
Ivan, 2012-04-13
@iSage

If ngix is ​​built from wiki.nginx.org/EmbeddedPerlModule then you can use it.

S
snp, 2012-04-13
@snp

A simple script in PHP or whatever that sends an X-Accel-Redirect (http://wiki.nginx.org/XSendfile)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question