找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1083|回复: 0

Nginx Echo模块使用

[复制链接]

304

主题

42

回帖

1338

积分

管理员

积分
1338
发表于 2021-4-16 03:18:32 | 显示全部楼层 |阅读模式
  1. #查看Nginx编译模块:
  2. /usr/local/nginx/sbin/nginx -V
  3. --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_random_index_module --with-http_sub_module

  4. #安装Echo模块:
  5. unzip echo-nginx-module-master.zip

  6. #给Nginx动态增加Echo模块:
  7. ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_random_index_module --with-http_sub_module --add-module=/mnt/echo-nginx-module-master

  8. #把Nginx重新编译:
  9. make

  10. #让新Nginx程序生效:
  11. pkill nginx
  12. cp /mnt/nginx-1.17.5/objs/nginx /usr/local/nginx/sbin/

  13. #重新启动Nginx:
  14. /usr/local/nginx/sbin/nginx

  15. #Echo模块测试:
  16. location /test {
  17.         echo "user123";
  18. }

  19. #Echo输出内置变量:
  20. location /test {
  21.         echo $remote_addr;
  22. }

  23. #变量定义与输出:
  24. location /test {
  25.         set $name user123;
  26.         echo $name;
  27. }

  28. #异步执行多location:
  29. location /echo1 {
  30.     echo_sleep 1;
  31.     echo '111';
  32. }

  33. location /echo2 {
  34.     echo_sleep 1;
  35.     echo '222';
  36. }

  37. location /main {
  38.       echo_reset_timer;

  39.       echo_location_async /echo1;
  40.       echo_location_async /echo2;

  41.       echo "took $echo_timer_elapsed sec for total.";
  42. }

  43. #同步执行多location:
  44. location /echo1 {
  45.     echo_sleep 1;
  46.     echo '111';
  47. }

  48. location /echo2 {
  49.     echo_sleep 2;
  50.     echo '222';
  51. }

  52. location /main {
  53.       echo_reset_timer;

  54.       echo_location /echo1;
  55.       echo_location /echo2;

  56.       echo "took $echo_timer_elapsed sec for total.";
  57. }

  58. #echo_duplicate重复多次输出:
  59. location /echo3 {
  60.     echo_duplicate 10 "hello ";
  61. }
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|外汇论坛 ( 粤ICP备16021788号 )

GMT+8, 2024-10-23 07:22 , Processed in 0.072310 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表