• 阿里Nginx替代产品-Tengine安装


    1、下载

    下载地址:下载 - The Tengine Web Server

    1. $ wget http://tengine.taobao.org/download/tengine-2.3.3.tar.gz #下载
    2. $ tar zxvf tengine-2.3.3.tar.gz #解压

    文档:文档 - The Tengine Web Server

    2、安装

    1. $ yum install -y zlib zlib-devel openssl openssl-devel pcre pcre-devel gcc gcc-c++ #安装依赖包
    2. $ ./configure --prefix=/usr/myapp/tengine --add-module=./modules/ngx_http_upstream_check_module
    3. $ make && make install

    官方文档写的是: 该模块可以为Tengine提供主动式后端服务器健康检查的功能。 该模块在Tengine-1.4.0版本以前没有默认开启,它可以在配置编译选项的时候开启:./configure --with-http_upstream_check_module

    执行时,会报错: $ ./configure --with-http_upstream_check_module
    ./configure: error: invalid option “–with-http_upstream_check_module”

    3、启动

    1. $ cd /usr/myapp/tengine
    2. $ sbin/nginx #启动

    4、配置

    1. #user nobody;
    2. worker_processes 1;
    3. #error_log logs/error.log;
    4. #error_log logs/error.log notice;
    5. #error_log logs/error.log info;
    6. #error_log "pipe:rollback logs/error_log interval=1d baknum=7 maxsize=2G";
    7. #pid logs/nginx.pid;
    8. events {
    9. worker_connections 1024;
    10. }
    11. http {
    12. include mime.types;
    13. default_type application/octet-stream;
    14. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    15. # '$status $body_bytes_sent "$http_referer" '
    16. # '"$http_user_agent" "$http_x_forwarded_for"';
    17. #access_log logs/access.log main;
    18. #access_log "pipe:rollback logs/access_log interval=1d baknum=7 maxsize=2G" main;
    19. sendfile on;
    20. #tcp_nopush on;
    21. #keepalive_timeout 0;
    22. keepalive_timeout 65;
    23. #gzip on;
    24. upstream cluster1 {
    25. # simple round-robin
    26. server 127.0.0.1:8080;
    27. server 127.0.0.1:8081;
    28. check interval=3000 rise=2 fall=5 timeout=1000 type=http;
    29. check_http_send "HEAD / HTTP/1.0\r\n\r\n";
    30. check_http_expect_alive http_2xx http_3xx;
    31. }
    32. server {
    33. listen 80;
    34. server_name localhost;
    35. #charset koi8-r;
    36. #access_log logs/host.access.log main;
    37. #access_log "pipe:rollback logs/host.access_log interval=1d baknum=7 maxsize=2G" main;
    38. location / {
    39. root html;
    40. index index.html index.htm;
    41. }
    42. # 健康检查测试
    43. location /test/ {
    44. proxy_pass http://cluster1/;
    45. }
    46. # 服务器状态的列表
    47. location /status {
    48. check_status;
    49. access_log off;
    50. allow all;
    51. #deny all;
    52. }
    53. #error_page 404 /404.html;
    54. # redirect server error pages to the static page /50x.html
    55. #
    56. error_page 500 502 503 504 /50x.html;
    57. location = /50x.html {
    58. root html;
    59. }
    60. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    61. #
    62. #location ~ \.php$ {
    63. # proxy_pass http://127.0.0.1;
    64. #}
    65. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    66. #
    67. #location ~ \.php$ {
    68. # root html;
    69. # fastcgi_pass 127.0.0.1:9000;
    70. # fastcgi_index index.php;
    71. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    72. # include fastcgi_params;
    73. #}
    74. # pass the Dubbo rpc to Dubbo provider server listening on 127.0.0.1:20880
    75. #
    76. #location /dubbo {
    77. # dubbo_pass_all_headers on;
    78. # dubbo_pass_set args $args;
    79. # dubbo_pass_set uri $uri;
    80. # dubbo_pass_set method $request_method;
    81. #
    82. # dubbo_pass org.apache.dubbo.samples.tengine.DemoService 0.0.0 tengineDubbo dubbo_backend;
    83. #}
    84. # deny access to .htaccess files, if Apache's document root
    85. # concurs with nginx's one
    86. #
    87. #location ~ /\.ht {
    88. # deny all;
    89. #}
    90. }
    91. # upstream for Dubbo rpc to Dubbo provider server listening on 127.0.0.1:20880
    92. #
    93. #upstream dubbo_backend {
    94. # multi 1;
    95. # server 127.0.0.1:20880;
    96. #}
    97. # another virtual host using mix of IP-, name-, and port-based configuration
    98. #
    99. #server {
    100. # listen 8000;
    101. # listen somename:8080;
    102. # server_name somename alias another.alias;
    103. # location / {
    104. # root html;
    105. # index index.html index.htm;
    106. # }
    107. #}
    108. # HTTPS server
    109. #
    110. #server {
    111. # listen 443 ssl;
    112. # server_name localhost;
    113. # ssl_certificate cert.pem;
    114. # ssl_certificate_key cert.key;
    115. # ssl_session_cache shared:SSL:1m;
    116. # ssl_session_timeout 5m;
    117. # ssl_ciphers HIGH:!aNULL:!MD5;
    118. # ssl_prefer_server_ciphers on;
    119. # location / {
    120. # root html;
    121. # index index.html index.htm;
    122. # }
    123. #}
    124. }

    健康检查接口为:http://127.0.0.1:8080、http://127.0.0.1:8081,要保证这两个有返回值。

  • 相关阅读:
    Laf v1.0 发布:函数计算只有两种,30s 放弃的和 30s 上线的
    【云原生 | 38】Docker快速部署开源脚本语言PHP
    面试高频考题解法——栈的压入弹出序列、有效的括号、逆波兰表达式求值
    数据库笔记——SQL语言DQL语句
    2082. 富有客户的数量
    QT 智能指针 QPointer QScopedPointer QSharedPointer QWeakPointer QSharedDataPointer 隐式共享 显示共享
    Python语言学习实战-内置函数all()和any()的使用(附源码和实现效果)
    使用pixy计算群体遗传学统计量
    ASP.NET的WebService跨域CORS问题解决方案
    2022-08-23 第六小组 瞒春 学习笔记
  • 原文地址:https://blog.csdn.net/xixingzhe2/article/details/119973717