Tengine的安装

部署说明

一、Tengine集群安装在10.135.64.100和10.135.64.101上

二、安装包拷贝

拷贝相关安装包到本地/app/downloads/下

pcre-8.35.tar.gz

nginx_tcp_proxy_module-master.zip

tengine-2.1.1.tar.gz

三、Tengine依赖环境的安装

1.gcc安装

yum -y install gcc gcc-c++ openssl-devel

2.pcre安装

tar -zxvf pcre-8.35.tar.gz

mv pcre-8.35 /app/lb/pcre-8.35

cd  /app/lb/pcre-8.35

./configure –prefix=/app/lb/pcre-8.35/

make && make install

3.安装nginx_tcp_proxy_module

cd /app/downloads/

#可以自选路径解压,这里解压到了/app/lb下,之后的操作路径注意保持一致

unzip nginx_tcp_proxy_module-master.zip -d /app/lb

4.Tengine安装

tar -zxvf tengine-2.1.1.tar.gz

cd  tengine-2.1.1

#下面的指令要找到上一步解压的文件夹下的tcp.pathch,路径是可变的

patch  -p1 </app/lb/nginx_tcp_proxy_module-master/tcp.patch

./configure –prefix=/app/lb/tengine-2.1.1/ –with-pcre=/app/lb/pcre-8.35/ –with-http_ssl_module –with-http_stub_status_module –with-http_realip_module –with-http_addition_module –with-http_sub_module –with-http_dav_module –with-http_flv_module –add-module=/app/lb/nginx_tcp_proxy_module-master

make && make install

四、Tengine配置

 

#user nobody;
worker_processes 1;

error_log logs/error/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;
events {
worker_connections 1024;
}

# load modules compiled as Dynamic Shared Object (DSO)
#
#dso {
# load ngx_http_fastcgi_module.so;
# load ngx_http_rewrite_module.so;
#}

http {
include mime.types;
default_type application/octet-stream;

log_format main ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;

access_log logs/access/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 5;

fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;

proxy_connect_timeout 10;
proxy_send_timeout 18000;
proxy_read_timeout 18000;
gzip on;
gzip_http_version 1.0;
gzip_disable “MSIE [1-6].”;
gzip_types application/json;

index index.html index.htm;

upstream web_cluster {
server x.x.x.x:8080;
server x.x.x.x:8080;
}

upstream TOKEN {
server x.x.x.x:8243;
server x.x.x.x:8243;
}

upstream AUTHORIZE {
server x.x.x.x:8243;
server x.x.x.x:8243;
}

upstream SP_VS {
server x.x.x.x:8080;
server x.x.x.x:8080;
}

upstream SP_PARKING {
server x.x.x.x:8080;
server x.x.x.x:8080;
}
server {
listen 80;
server_name _;
charset utf-8;
ignore_invalid_headers off;

location /ngx_status
{
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}

location /sp-parking {
proxy_pass http://SP_PARKING;
}

location /sp-vs {
proxy_pass http://SP_VS;
}
#access_log logs/host.access.log main;

location / {
root /var/www/html;
index index.html index.htm;
}
#error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

server {
listen 443;
server_name _;
charset utf-8;
ignore_invalid_headers off;
ssl on;
ssl_certificate /app/lb/tengine-2.1.1/apache.crt;
ssl_certificate_key /app/lb/tengine-2.1.1/apache.key;

#ssl_session_cache shared:SSL:1m;
#ssl_session_timeout 600m;
#ssl_session_tickets on;
#ssl_session_ticket_key /app/lb/tengine-2.1.1/ticket.key;

ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location /token {
proxy_pass https://TOKEN;
}

location /authorize {
proxy_pass https://AUTHORIZE;
}
#access_log logs/host.access.log main;

location / {
root /var/www/html;
index index.html index.htm;
}

rewrite ^/oapi/token /token last;
rewrite ^/oapi/authorize(.*) /authorize$1 last;
rewrite ^/oapi/revoke /revoke last;
rewrite ^/oapi/vip(.*) /vip$1 last;

#error_page 404 /404.html;

#rewrite ^/sp-vs-web/(.*) /$1 last;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

server {
listen 8088;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
proxy_pass http://web_cluster;
}

location /ngx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
#location ~ /\.ht {
# deny all;
#}
}
}