Answer the question
In order to leave comments, you need to log in
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
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. 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
If ngix is built from wiki.nginx.org/EmbeddedPerlModule then you can use it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question