Use the Magical Nginx--with-stream module on the cloud service to open the MySQL extranet address

Source: Internet
Author: User

because sometimes there is a demand, need to open the Cloud database network address, but there are individual cloud operators do not provide this operation, after a few brainstorming, think of Nginx on another--with-stream module can map the intranet IP port to the external network address! This does not solve the demand!!!


First look at Nginx there is no this module, do not compile the installation:

[Email protected] ~]#/usr/local/nginx/sbin/nginx-v

Nginx version:openresty/1.9.7.4

Built by GCC 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)

Built with OpenSSL 1.0.2k-fips 2017 Jan

TLS SNI Support Enabled

Configure arguments:--prefix=/usr/local/nginx--with-cc-opt=-o2--add-module=. /ngx_devel_kit-0.2.19--add-module=. /echo-nginx-module-0.58--add-module=. /xss-nginx-module-0.05--add-module=. /NGX_COOLKIT-0.2RC3--add-module=. /set-misc-nginx-module-0.30--add-module=. /form-input-nginx-module-0.11--add-module=. /encrypted-session-nginx-module-0.04--add-module=. /drizzle-nginx-module-0.1.9--add-module=. /srcache-nginx-module-0.30--add-module=. /ngx_lua-0.10.2--add-module=. /ngx_lua_upstream-0.05--add-module=. /headers-more-nginx-module-0.29--add-module=. /array-var-nginx-module-0.05--add-module=. /memc-nginx-module-0.16--add-module=. /redis2-nginx-module-0.12--add-module=. /redis-nginx-module-0.3.7--add-module=. /rds-json-nginx-module-0.14--add-module=. /rds-csv-nginx-module-0.07--with-ld-opt=-wl,-rpath,/usr/local/luajit/lib--conf-path=/etc/nginx/nginx.conf-- User=www--group=www--with-http_stub_status_module--with-http_gzip_static_module--with-http_realip_module--wIth-http_ssl_module--add-module=/root/src/gnosek-nginx-upstream-fair-a18b409--add-module=/root/src/ngx_cache_ purge-2.3--add-module=/root/src/nginx-http-concat--with-http_v2_module--with-stream


Compile and install:

CD/ROOT/SRCCD openresty-1.11.2.5./configure--prefix=/usr/local--conf-path=/etc/nginx/nginx.conf--user=www-- Group=www--with-http_stub_status_module--with-http_gzip_static_module--with-http_realip_module--with-http_ssl_ Module--add-module=/root/src/gnosek-nginx-upstream-fair-a18b409--add-module=/root/src/ngx_cache_purge-2.3-- Add-module=/root/src/nginx-http-concat--with-luajit--with-http_v2_module--with-http_drizzle_module--  WITH-STREAMIF Make-j8;then make Installelse exit 1fimkdir-p/etc/nginx/vhostmkdir-p/usr/local/nginx/tempmkdir-p /usr/local/nginx/cachechown Www:www/usr/local/nginx/tempchown www:www/usr/local/nginx/cache/bin/cp-f/root/src/ Nginx.conf/etc/nginx/nginx.conf


Start configuration Stream

[Email protected] ~]# Vim/etc/nginx/nginx.confuser www www;.................stream {upstream mysql_3306 {ser    Ver 192.168.1.5:3306;        } server {Listen 3306;        Proxy_connect_timeout 20s;    Proxy_pass mysql_3306; }}


Restart Nginx:

[Email protected] ~]#/usr/local/nginx/sbin/nginx-t

[Email protected] ~]#/usr/local/nginx/sbin/nginx-s Reload


Test:

The test uses an extranet address that's already connected.


Use the Magical Nginx--with-stream module on the cloud service to open the MySQL extranet address

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.