nginx socket转发设置
2017-10-13 22:10
453 查看
1.添加依赖模块,如下
2.nginx.conf 配置,参考说明:ngx_stream_core_module
请注意,stream配置不能放到http内,即不能放到/etc/nginx/conf.d/,因为stream是通过tcp层转发,而不是http转发。
如配置在http内,启动nginx会报如下错误:
3.在tcp.d下新建个bss_num_30001.conf文件,内容如下:
--with-stream --with-stream_ssl_module
2.nginx.conf 配置,参考说明:ngx_stream_core_module
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; } }
相关文章推荐
- nginx 设置多个tcp IP代理 socket 转发
- Websocket+nginx转发404问题
- 015_NGINX作为WebSocket Proxy的设置
- Nginx支持Socket转发过程详解
- Nginx 配置socket转发
- nginx证书制作以及配置https并设置访问http自动跳转https(反向代理转发jboss)
- Nginx支持Socket转发过程详解
- 在nginx中设置socket缓冲区大小
- nginx 的多域名多https转发设置方法【转】
- Nginx支持socket转发
- Nginx设置404页面转发
- Nginx支持Socket转发过程详解
- Apache/nginx转发设置-分布式部署
- Nginx反向代理转发Host设置
- Android开发——本机Tomcat搭建服务器,客户端socket网络连接不上问题以及D-LINK端口转发设置
- Nginx支持Socket转发过程详解
- 设置nginx反向代理将80端口转发到9999端口
- windows下Nginx实现socket转发功能
- Apache/nginx转发设置-分布式部署
- Nginx支持Socket转发过程详解