Donโt be afraid, because the brave group of Ops programmers has decided the situation with the brand spanking the new nginx_tcp_proxy_module
Written in August 2012, so if you are from the future, you should do your homework.
The necessary conditions
It is assumed that you are using CentOS:
- Delete the current instance of NGINX (suppose a dev server is used for this)
- If possible, save the old NGINX configuration files so that they can be reused (including your
init.d/nginx script) yum install pcre pcre-devel openssl openssl-devel and any other necessary libraries for creating NGINX- Get nginx_tcp_proxy_module from GitHub here https://github.com/yaoweibin/nginx_tcp_proxy_module and remember the folder where you placed it (make sure it is not zipped)
Create your new NGINX
Again, CentOS suggests:
cd /usr/local/wget 'http://nginx.org/download/nginx-1.2.1.tar.gz'tar -xzvf nginx-1.2.1.tar.gzcd nginx-1.2.1/patch -p1 < /path/to/nginx_tcp_proxy_module/tcp.patch./configure --add-module=/path/to/nginx_tcp_proxy_module --with-http_ssl_module (you can add more modules if you need them)makemake install
Additionally:
sudo /sbin/chkconfig nginx on
Configure Nginx
Remember to copy the old configuration files first if you want to reuse them.
Important: you will need to create the tcp {} directive at the highest level in your conf. Make sure it is not in your http {} directive.
The following configuration example shows one upstream web server and two proxies for SSL and Non-SSL.
tcp { upstream websockets { ## webbit websocket server in background server 127.0.0.1:5501; ## server 127.0.0.1:5502; ## add another server if you like! check interval=3000 rise=2 fall=5 timeout=1000; } server { server_name _; listen 7070; timeout 43200000; websocket_connect_timeout 43200000; proxy_connect_timeout 43200000; so_keepalive on; tcp_nodelay on; websocket_pass websockets; websocket_buffer 1k; } server { server_name _; listen 7080; ssl on; ssl_certificate /path/to/cert.pem; ssl_certificate_key /path/to/key.key; timeout 43200000; websocket_connect_timeout 43200000; proxy_connect_timeout 43200000; so_keepalive on; tcp_nodelay on; websocket_pass websockets; websocket_buffer 1k; } }
crockpotveggies Aug 24 '12 at 1:23 2012-08-24 01:23
source share