http通道连接mysql_通过http tunnel连接mysql
在/etc/nginx/nginx.conf的第一行加上
load_module /usr/lib64/nginx/modules/ngx_http_proxy_connect_module.so;
nginx -s reload
> ```nginx: [emerg] dlopen() "/usr/lib64/nginx/modules/ngx_http_proxy_connect_module.so" failed (/usr/lib64/nginx/modules/ngx_http_proxy_connect_module.so: cannot open shared object file: No such file or directory) in /etc/nginx/nginx.conf```
又要開始折騰了, 沒有ngx_http_proxy_connect_module, google了一把, ngx_http_proxy_connect_module
相當(dāng)于重新編譯nginx, 有幾個(gè)坑, 不過意外發(fā)現(xiàn)有個(gè)go的開源庫,專門編譯nginx,剛好我是go開發(fā),go的庫nginx-build, 但是下面說的跟這個(gè)庫沒關(guān)系, 只是打個(gè)go的廣告^_^
(1) 選定對應(yīng)的nginx源碼zip,更改nginx的version, nginx -v
(2) ./configure的編譯參數(shù), 需要提前nginx -V復(fù)制之前的啟動參數(shù)下來
(3) 執(zhí)行path的時(shí)候需要看`https://github.com/chobits/ngx_http_proxy_connect_module`的說明,哪個(gè)版本用哪個(gè)patch
$ git clone https://github.com/chobits/ngx_http_proxy_connect_module.git /root/ngx_http_proxy_connect_module
$ wget http://nginx.org/download/nginx-1.12.2.tar.gz
$ tar -xzvf nginx-1.12.2.tar.gz
$ cd nginx-1.12.2/
$ patch -p1 < /root/ngx_http_proxy_connect_module/patch/proxy_connect.patch
$ ./configure --add-module=/root/ngx_http_proxy_connect_module ·后面接上nginx -V里面的configure arguments·
$ make && make install
$ cp /root/ngx_http_proxy_connect_module
執(zhí)行過程
$ ./configure --add-dynamic-module=/root/ngx_http_proxy_connect_module --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'
出現(xiàn)各種錯(cuò)誤,各種google,最終
yum -y install redhat-rpm-config.noarch
yum -y install libxslt-devel
yum -y install perl-devel perl-ExtUtils-Embed
yum -y install gd-devel
yum -y install geoip-devel
yum -y install gperftools-devel
最后編譯只出現(xiàn)warning類的報(bào)錯(cuò)才算成功
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/share/nginx"
nginx binary file: "/usr/sbin/nginx"
nginx modules path: "/usr/lib64/nginx/modules"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
nginx pid file: "/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/var/lib/nginx/tmp/client_body"
nginx http proxy temporary files: "/var/lib/nginx/tmp/proxy"
nginx http fastcgi temporary files: "/var/lib/nginx/tmp/fastcgi"
nginx http uwsgi temporary files: "/var/lib/nginx/tmp/uwsgi"
nginx http scgi temporary files: "/var/lib/nginx/tmp/scgi"
./configure: warning: the "--with-ipv6" option is deprecated
ls /usr/lib64/nginx/modules 就會發(fā)現(xiàn)ngx_http_proxy_connect_module.so文件已經(jīng)生成了, /usr/lib64/nginx/modules是modules路徑, nginx -V可以看到–modules-path
開始配置nginx
stream {
server {
listen 443;
server_name t1.test.example.com;
proxy_connect;
proxy_connect_allow 443;
proxy_connect_connect_timeout 10s;
proxy_connect_read_timeout 10s;
proxy_connect_send_timeout 10s;
proxy_pass http://$http_host;
}
}
尷尬的發(fā)現(xiàn)到這里又做下不去了,只能轉(zhuǎn)發(fā)http的流量,無法利用http的tunnel改為tcp流量,到此結(jié)束
總結(jié)
以上是生活随笔為你收集整理的http通道连接mysql_通过http tunnel连接mysql的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: qt html导pdf 页眉,如何使用w
- 下一篇: 用递归与分治策略求解网球循环赛日程表_算