我想使用Nginx1.9作为TCP负载均衡器。我遵循了https://www.nginx.com/resources/admin-guide/tcp-load-balancing/中的教程,但没有起作用。
每次我试着启动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;
}
}请告诉我怎么配置好吗?
发布于 2016-01-06 16:46:39
最好的方法是从源代码编译nginx以支持stream指令:
./configure --prefix=/opt/nginx --sbin-path=/usr/sbin/nginx --conf-path=/opt/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --with-http_ssl_module --with-threads --with-stream --with-http_slice_module
make
sudo make install发布于 2016-06-20 08:19:06
在OS上使用自制软件,可以通过以下方法完成:
brew install nginx-full --with-stream这可能要求您首先安装homebrew-nginx龙头,在这种情况下,您可能必须运行
brew install homebrew/nginx/nginx-full --with-stream以确保先安装水龙头。
发布于 2016-08-09 04:09:59
如果您使用的是linux,则有nginx标准库。
https://stackoverflow.com/questions/34615146
复制相似问题