Nginx 实现tcp反向代理(Linux上)
2016-06-05 13:48
477 查看
Tcp代理模块配置
下载tcp代理模块:
wget https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master.zip
解压后,在nginx的安装目录下执行如下两条命令:
在/urs/local/nginx/conf 目录下的nginx.conf配置文件中添加如下代码:
tcp {
upstream firefoxbug {
# simple round-robin
server 192.168.152.128:22;
#check interval=3000 rise=2 fall=5 timeout=1000;
#check interval=3000 rise=2 fall=5 timeout=1000 type=ssl_hello;
#check interval=3000 rise=2 fall=5 timeout=1000 type=http;
#check_http_send "GET / HTTP/1.0\r\n\r\n";
#check_http_expect_alive http_2xx http_3xx;
}
server {
listen 1234;
proxy_pass firefoxbug;
}
}
如图:
然后在nginx安装目录下执行:sudo make 和 sudo make install
配置完成。
若出现如下问题:
表明在配置tcp代理模块的make install过程中没有加sudo 导致从当前用户向/usr/local/nginx/中写文件时权限不够导致的。
下载tcp代理模块:
wget https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master.zip
解压后,在nginx的安装目录下执行如下两条命令:
在/urs/local/nginx/conf 目录下的nginx.conf配置文件中添加如下代码:
tcp {
upstream firefoxbug {
# simple round-robin
server 192.168.152.128:22;
#check interval=3000 rise=2 fall=5 timeout=1000;
#check interval=3000 rise=2 fall=5 timeout=1000 type=ssl_hello;
#check interval=3000 rise=2 fall=5 timeout=1000 type=http;
#check_http_send "GET / HTTP/1.0\r\n\r\n";
#check_http_expect_alive http_2xx http_3xx;
}
server {
listen 1234;
proxy_pass firefoxbug;
}
}
如图:
然后在nginx安装目录下执行:sudo make 和 sudo make install
配置完成。
若出现如下问题:
表明在配置tcp代理模块的make install过程中没有加sudo 导致从当前用户向/usr/local/nginx/中写文件时权限不够导致的。
相关文章推荐
- Linux下基于http的小型web服务器编写
- 计算机网络简介
- HttpSession与Hibernate中Session的区别
- 网络编程课程复习
- 制作本地yun源 http方式的详解
- httpd之禁止解析php
- note04-计算机网络
- httpd日志记录客户端请求的域名
- TCP,UDP,三次握手
- httpd之日志切割
- BZOJ_1491_[NOI2007]社交网络_最短路径
- Java#Servlet规范#HTTP Protocol Parameters
- 轮询程序中使用的各种方法:spring调用;http调用;存储过程调用;
- httpd之不记录指定文件类型的日志
- httpd之拒绝某些user_agent
- http认证与portal认证
- Http status: 200 OK ajaxOptions: parsererror thrownError: SyntaxError: Unexpected token < in JSON at
- httpd之域名301跳转
- 遗传算法优化的BP神经网络建模
- tcp/ip定时器