nginx TCP 转发配置
来源:互联网 发布:php 存储json 编辑:程序博客网 时间:2024/05/21 17:08
今天有客户需要增加移动线路,但机房刚好移动线路还没有开通,试用了一下转发。效果还不错
客户需求是 服务器只做TCP服务,对应的是7000 7001 7002 7003 转发
先在移动机房增加一台CENTOS 6.5 64位 服务器安装好NGINX等组件
最好是安装1.9版本以上的
一、安装编译工具及库文件
#yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
#./configure --with-stream#make
#make install
# /usr/local/nginx/sbin/nginx #启动
测试提示:/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
linux 64位安装nginx后启动出错报以下错误
#/usr/local/nginx/sbin/nginx
error
while
loading shared libraries: libpcre.so.
1
:
cannot open shared object file: No such file or directory
从错误看出是缺少lib文件导致,进一步查看下
1
2
3
4
5
6
7
8
9
10
[root
@localhost
nginx-
1.10
.
0
]# ldd $(which /usr/local/nginx/sbin/nginx)
linux-vdso.so.
1
=> (
0x00007fff4d5ff000
)
libpthread.so.
0
=> /lib64/libpthread.so.
0
(
0x00007fea7e357000
)
libcrypt.so.
1
=> /lib64/libcrypt.so.
1
(
0x00007fea7e120000
)
libpcre.so.
1
=> not found
libz.so.
1
=> /lib64/libz.so.
1
(
0x00007fea7df09000
)
libc.so.
6
=> /lib64/libc.so.
6
(
0x00007fea7db76000
)
/lib64/ld-linux-x86-
64
.so.
2
(
0x00007fea7e57d000
)
libfreebl3.so => /lib64/libfreebl3.so (
0x00007fea7d913000
)
libdl.so.
2
=> /lib64/libdl.so.
2
(
0x00007fea7d70f000
)
可以看出 libpcre.so.1 => not found 并没有找到,进入/lib64目录中手动链接下
1
2
[root
@localhost
/]# cd lib64/
[root
@localhost
lib64]# ln -s libpcre.so.
0.0
.
1
libpcre.so.
1
然后启动nginx就ok了
#pkill -9 nginx 强制结束
# /usr/local/nginx/sbin/nginx -v #查看nginx 支持模块
# /usr/local/nginx/sbin/nginx -t # 检查语法
配置nginx.conf 在最后添加如入:
stream {
upstream 7000 {hash $remote_addr consistent;
server 12.12.12.12:7000 max_fails=3 fail_timeout=30s;
}
upstream 7001 {
hash $remote_addr consistent;
server 12.12.12.12:7001 max_fails=3 fail_timeout=30s;
}
upstream 7002 {
hash $remote_addr consistent;
server 12.12.12.12:7002 max_fails=3 fail_timeout=30s;
}
upstream 7003 {
hash $remote_addr consistent;
server 12.12.12.12:7003 max_fails=3 fail_timeout=30s;
}
server {
listen 7000;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 7000;
}
server {
listen 7001;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 7001;
}
server {
listen 7002;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 7002;
}
server {
listen 7003;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 7003;
}
}
nginx 重启
#pkill -9 nginx 强行结束进程
# /usr/local/nginx/sbin/nginx 启动进程
1 0
- nginx TCP转发配置
- nginx TCP 转发配置
- Nginx转发代理配置
- nginx 配置端口转发
- nginx配置转发
- nginx转发websocket配置
- Nginx 转发配置
- nginx配置url转发
- nginx转发配置
- nginx配置proxy_pass代理转发
- Nginx 配置子域名转发
- nginx 配置转发到tomcat
- Nginx配置proxy_pass 转发问题
- nginx转发方式的配置
- ubuntu配置apache2的nginx的转发
- Nginx配置proxy_pass转发的/路径问题
- nginx静态化文件转发规则配置
- 将nginx配置成url_hash转发方式
- Centos 下搭建FTP上传下载服务器
- oracle过滤重复数据,只保留一条
- Qt 信号和槽详解
- 银联Pos终端签到、签退、批结算、批上送、PinKey、MacKey、KEK、主密钥、工作密钥、TPDU、报文头
- Android Telephony分析(三) ---- RILJ详解
- nginx TCP 转发配置
- android studio git使用上传新项目、更新、提交
- NYOJ 513 A+B Problem IV(java)
- 使用WinSCP软件在windows和ubuntu中进行文件传输
- Spring mvc + Mybatis Maven
- Java虚拟机--常用的GC参数(十)
- javasctipt 数组原生方法大集合
- 【Java8】Guava——Preconditions
- memcached与redis实现的对比