【发布时间】:2016-06-03 09:46:53
【问题描述】:
问题:是否可以将 Nginx 设置为数据库的反向代理?
这些是我目前拥有的标志,我相信拥有 --with-stream 模块足以使用 TCP 流到数据库。这是 PLUS 功能吗?
Nginx 配置选项:
--prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=%{_libdir}/nginx/modules --conf-path=/etc/nginx/nginx. conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx。 pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/ nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/ var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --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_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with -http_slice_module --with-邮件 --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE =2' --with-ld-opt='-Wl,-z,relro -Wl,--as-needed' --with-ipv6
Nginx 配置
stream {
include conf.d/streams/*.conf;
}
conf.d/streams/upstream.conf的内容
upstream database_server {
least_conn;
keepalive 512;
server 192.168.99.103:32778 max_fails=5 fail_timeout=30s weight=1;
}
来自 Nginx 的错误消息
2016/02/22 03:54:13 [emerg] 242#242:/etc/nginx/conf.d/streams/database_server.conf:9 中上游“http://database_server”中的主机无效
【问题讨论】:
标签: database postgresql nginx reverse-proxy