anh*_*dbk 7 tcp load-balancing nginx
我想使用Nginx 1.9作为TCP负载均衡器.我按照https://www.nginx.com/resources/admin-guide/tcp-load-balancing/中的教程进行了操作,但它没有用.
每当我尝试启动nginx时,我都会遇到错误:
nginx: [emerg] unknown directive "stream" in /opt/nginx/nginx.conf
Run Code Online (Sandbox Code Playgroud)
这是我的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;
}
}
Run Code Online (Sandbox Code Playgroud)
你能告诉我如何配置它吗?
最好的方法是从源代码编译nginx到support 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
Run Code Online (Sandbox Code Playgroud)
在OS X上使用Homebrew,可以通过以下方式完成:
brew install nginx-full --with-stream
Run Code Online (Sandbox Code Playgroud)
这可能会要求您先安装homebrew-nginx水龙头,在这种情况下您可能需要运行
brew install homebrew/nginx/nginx-full --with-stream
Run Code Online (Sandbox Code Playgroud)
确保首先安装水龙头.
| 归档时间: |
|
| 查看次数: |
13527 次 |
| 最近记录: |