博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx socket转发设置
阅读量:4589 次
发布时间:2019-06-09

本文共 884 字,大约阅读时间需要 2 分钟。

1.添加依赖模块,如下

--with-stream --with-stream_ssl_module

2.nginx.conf 配置,参考说明:

user nginx;worker_processes 1;error_log /var/log/nginx/error.log warn;pid /var/run/nginx.pid;events {worker_connections 1024;}http {.................}# tcp层转发的配置文件夹include /etc/nginx/tcp.d/*.conf;

请注意,stream配置不能放到http内,即不能放到/etc/nginx/conf.d/,因为stream是通过tcp层转发,而不是http转发。

如配置在http内,启动nginx会报如下错误:

nginx: [emerg] "server" directive is not allowed here

3.在tcp.d下新建个bss_num_30001.conf文件,内容如下:

stream {
  #添加socket转发的代理 upstream proxy_forward { hash $remote_addr consistent; server 139.196.172.xx:80; #server 139.224.18.xx:80; #ip_hash; }  #提供转发服务,即访问forward.xxx.cn:80,并配置好请求头,会调整至proxy_forward指定的地址 server { #listen 127.0.0.1:80; listen forward.xxx.cn:80; proxy_pass xdaili_forward; }}

 

转载于:https://www.cnblogs.com/vijayfly/p/7663552.html

你可能感兴趣的文章
Amazon AWS EC2存储
查看>>
Amazon S3和EBS的区别
查看>>
AWS云管理平台
查看>>
NoSQL SimpleDB
查看>>
连接RDS数据库
查看>>
操作RDS数据库
查看>>
分布式并行编程
查看>>
swoolefy PHP的异步、并行、高性能网络通信引擎内置了Http/WebSocket服务器端/客户端...
查看>>
Python学习笔记
查看>>
unshift()与shift()
查看>>
使用 NPOI 、aspose实现execl模板公式计算
查看>>
行为型模式:中介者模式
查看>>
How to Notify Command to evaluate in mvvmlight
查看>>
STL容器内数据删除
查看>>
33. Search in Rotated Sorted Array
查看>>
461. Hamming Distance
查看>>
Python垃圾回收机制详解
查看>>
{面试题1: 赋值运算符函数}
查看>>
Node中没搞明白require和import,你会被坑的很惨
查看>>
Python 标识符
查看>>