我想使用Nginx 1.9作为TCP负载均衡器。我按照https://www.nginx.com/resources/admin-guide/tcp-load-balancing/中的教程进行操作,但是没有成功。
每次尝试启动nginx时,都会出现错误:
每次尝试启动nginx时,都会出现错误:
nginx: [emerg] unknown directive "stream" in /opt/nginx/nginx.conf
这是我的 nginx.conf 文件:
events {
worker_connections 1024;
}
http {
# blah blah blah
}
stream {
upstream backend {
server 127.0.0.1:9630;
server 127.0.0.1:9631;
}
server {
listen 2802;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass backend;
}
}
请问如何正确配置它?
--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-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-ipv6
- DanielSmedegaardBuusbrew install homebrew/nginx/nginx-full --with-stream --with-stream_ssl_module
。它似乎只是剥离了后者(以及任何未知的参数)。我可以通过nginx -V
来验证这一点。实际上,在@DanielSmedegaardBuus发布的列表中,只有--with-mail
和--with-stream
似乎有效。我通过在我的Linux虚拟机上安装解决了这个问题,但也许这里有人知道使用brew的解决方案? - Johannes Hoff