2021 tengine 有了小版本的更新 ,这次都是采用最新的软件包安装。
一:安装包下载如下:
tengine:
http://tengine.taobao.org/download/tengine-2.3.3.tar.gz
openssl:
https://www.openssl.org/source/openssl-1.1.1k.tar.gz
jemalloc:
https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2
luajit2:
git clone https://github.com/openresty/luajit2
二:编译如下:
可以参考:https://wenda.zuncuang.com/article/430
需要注意的是:jemalloc不需要编译,解压后,直接指定路径就可以了,
openssl和 luajit2 都需要编译后,然后才能加载对应库文件,
./configure --prefix=/usr/local/tengine --with-jemalloc --with-jemalloc=/root/jemalloc-5.2.1 --with-pcre --with-stream=dynamic --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-openssl=/usr/local/openssl-111k --with-http_lua_module --with-luajit-lib=/usr/local/lib/ --with-luajit-inc=/usr/local/include/luajit-2.1/ --with-lua-inc=/usr/local/include/luajit-2.1/ --with-lua-lib=/usr/local/lib/ --add-module=modules/ngx_http_upstream_check_module
【PS:tengine-2.3.3 下 后端检测模块,已经作为一个第三方模块,默认不会安装,也不会在configure --help 中显示,需要在在编译的时候作为第三方模块编译安装】
然后 make;make install
三:配置TCP 代理如下
user www;
worker_processes auto;
worker_cpu_affinity auto;
error_log logs/error.log crit;
#error_log logs/error.log debug;
worker_rlimit_nofile 65535 ;
pid logs/nginx.pid;
#加载tcp代理模块
load_module "modules/ngx_stream_module.so";
events {
use epoll;
multi_accept on;
worker_connections 65535;
}
### http 配置部分
http {
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
log_not_found off;
types_hash_max_size 2048;
client_max_body_size 16M;
# MIME
include mime.types;
default_type application/octet-stream;
# gzip
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
server_tag Apache/2.4.23; #Server头癿伪装
server_info off; #错误信息
server_admin support@sthmei.com; #便于定位用户反馈癿4xx和5xx错误
log_format access '"$http_x_forwarded_for" $remote_addr $host $remote_user [$time_local] "$request" '
'$status $body_bytes_sent $request_body "$http_referer" '
'"$http_user_agent" "$upstream_response_time" "$request_time"';
include /webdata/conf/*.conf;
}
#### TCP代理部分
stream {
log_format proxy '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
include /webdata/conf/tcp/lbs-6443.conf;
}
其中 lbs-6443.conf 文件配置如下:
upstream slb_port_6443 {
hash $remote_addr consistent;
server 192.168.1.160:6443 weight=1 max_fails=3 fail_timeout=2s;
#server 192.168.1.66:443 weight=1 max_fails=3 fail_timeout=2s;
#server 192.168.1.67:443 weight=1 max_fails=3 fail_timeout=2s;
}
server {
listen 192.168.1.188:6443;
proxy_next_upstream on;
proxy_next_upstream_timeout 0;
proxy_next_upstream_tries 0;
proxy_connect_timeout 60s;
proxy_timeout 1m;
proxy_upload_rate 0;
proxy_download_rate 0;
proxy_pass slb_port_6443;
}
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!