在 FreeBSD 机器上,我有一个 super 简单的 Nginx conf 文件 (nginx/1.8.1):
server {
server_name .domain1.com;
listen 80 accept_filter=httpready;
index index.html;
location / {
root /home/www1;
}
}
server {
server_name domain2.com;
listen 80 default_server accept_filter=httpready;
index index.htm;
location / {
root /home/www2;
}
}
如果我只为其中一台服务器启用了 accept_filter=httpready
,则此方法有效。但正如上面所写,它失败了,并显示
nginx:[emerg] 0.0.0.0:80 的重复监听选项
为什么我无法为两台服务器设置 accept_filter=httpready
?
最佳答案
The
listen
directive can have several additional parameters specific to socket-related system calls. These parameters can be specified in anylisten
directive, but only once for a givenaddress:port
pair.
因此,您应该仅使用 accept_filter=httpready
一次,但它将对监听同一 address:port
的所有服务器 block 有效。
关于Nginx:如何使用accept_filter = httpready设置多个服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36473527/