如何设置在nginx的configuration没有第三方模块的variables指定范围内的随机值?
就像是
set $random_value rand(1,4);
使用macports:
读完那些https://trac.macports.org/ticket/19342 https://stackoverflow.com/questions/7812596/installing-nginx-via-macports-with-ngx-echo-module-available
(必须是perl 5.8或5.10)
# port -f install perl5 +perl5_8 # port clean nginx # port install nginx +perl5
我不能发布更多的链接,findNginx网站上的/ HttpEchoModule#安装
cd /opt/local/src/
在这里下载tgz: https : //github.com/agentzh/echo-nginx-module/downloads tar -zxvf /Users/lorieri/Downloads/agentzh-echo-nginx-module-v0.37rc7-1-gb0e0a23.tar。 GZ
port edit nginx
添加这些行之间的任何其他变种
variant echo description {Add echo } { configure.args-append --add-module=/opt/local/src/agentzh-echo-nginx-module-b0e0a23 }
然后…
# port install -v nginx +perl5 +echo
编辑/ opt / local / etc / nginx并在前面(下面)注释中提及,在http上下文中编辑相同的文件以添加testing位置
location /lorieri { default_type text/plain; echo $rnd; }
运行nginx
# nginx
testing它与curl,wget,您的浏览器…
# curl localhost/lorieri 9 # curl localhost/lorieri 8 # curl localhost/lorieri 8 # curl localhost/lorieri 9 # curl localhost/lorieri 6
为什么我这样做? 在nginx上设置一年的cookie user_uid和当前会话的一个随机的cookie
http { perl_set $rnd 'sub { return int(rand(10 - 5)) + 5; }'; ... }
使用perl模块。
这种caching的目标是什么?