In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to use Nginx to achieve port forwarding TCP agent". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Background of demand generation
Recently, my colleague deployed a set of applications in the test and production environments respectively. Because the application can only integrate LDAP, and our company uses AD, I set up an OpenLDAP service, where the account is synchronized from AD to OpenLDAP through lsc, and then uses saslauthd to pass authentication to AD. In the test environment, our application can connect to LDAP and log in, but in the production environment, we cannot access the OpenLDAP server. I don't want to reinstall and maintain a set of OpenLDAP services in the production environment. This process is tedious, and we need to synchronize the AD account with OpenLDAP every day through scheduled tasks, so I think this can be achieved through port forwarding, and the topology between nodes is like this.
Why use Nginx to implement
There are many ways to search for port forwarding on Baidu, most of which are achieved through Iptables, but I have tested it on Ubuntu and CentOS servers respectively and have no choice but to choose Nginx to achieve it.
Using Nginx to realize Port forwarding
If our operating system is relatively new, we can install nginx directly from the software source. As long as the nginx version is greater than 1.9, the TCP agent is supported by default.
Check whether nginx supports TCP proxy
Nginx-V
When we include-- with-stream in the configuration parameters of the output, it indicates that nginx is a TCP agent.
Installation dependency
RHEL/CentOS/Fedora
Yum install-y pcre* openssl*
Debian/Ubuntu
Apt-get install zlib1g-dev libpcre++-dev openssl
Download dependency
Download and install wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gztar-zxvf ngx_cache_purge-2.3.tar.gz-C / usr/local/src
Download the source package
Wget http://nginx.org/download/nginx-1.9.9.tar.gz
Decompression
Tar-zxf nginx-1.9.9.tar.gz
Compilation and installation
Cd nginx-1.9.9./configure-prefix=/usr/local/nginx\-add-module=/usr/local/src/ngx_cache_purge-2.3\-with-http_stub_status_module-with-streammake & & make install
Modify the configuration file
/ usr/local/nginx/conf/nginx.conf
Events {...} stream {upstream ldap {hash $remote_addr consistent; server 192.168.1.8 http 389;} server {listen 1389; proxy_connect_timeout 5s; proxy_timeout 5s; proxy_pass ldap;}} http {...}
In this example, we forward the local port 1389 to port 389 of 192.168.1.8.
Start and check if the service is working properly
Start the nginx service
/ usr/local/nginx/sbin/nginx
Check the nginx process
Netstat-anput | grep nginx
This is the end of the content of "how to use Nginx to achieve port forwarding TCP proxy". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.