nginx之TCP反向代理
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx之TCP反向代理相关的知识,希望对你有一定的参考价值。
nginx从1.9.0后引入模块ngx_stream_core_module,模块是没有编译的,需要用到编译需添加--with-stream配置参数,stream负载均衡官方配置样例
user nginx; #user root; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } stream{ upstream mysql{ server 192.168.1.106:3306 weight=1; server 192.168.1.108:3306 weight=1; } server{ listen 3307; proxy_pass mysql; } }
stream 与 http 是一个层级的,放在配置文件最后
本文出自 “墨” 博客,请务必保留此出处http://jinyudong.blog.51cto.com/10990408/1911524
以上是关于nginx之TCP反向代理的主要内容,如果未能解决你的问题,请参考以下文章