nginx未知指令“keepalive”

时间:2013-04-30 16:38:03

标签: nginx

我使用以下配置

upstream site {
    server 127.0.0.1:3000;
    keepalive 64;
}

server {
    listen 80;

    error_page 400 404 500 502 503 504 /50x.html;
    location  /50x.html {
            internal;
            root /usr/share/nginx/www;
    }

    location /static {
        root /opt/site/static;
        access_log off;
        expires max;
    }

    location / {
        proxy_redirect off;
        proxy_set_header   X-Real-IP            $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host                   $http_host;
        proxy_set_header   X-NginX-Proxy    true;
        proxy_set_header   Connection "";
        proxy_http_version 1.1;
        proxy_pass         http://site;
        proxy_intercept_errors on;
    }
}

我已将其保存到/etc/nginx/sites-available/site.conf并将其符号链接到/etc/sites-enabled/site.conf,当我重新启动nginx时,它给出了以下错误:

Restarting nginx: [emerg]: unknown directive "keepalive" in /etc/nginx/sites-enabled/site.conf:3

2 个答案:

答案 0 :(得分:2)

没有keepalive指令。请改用keepalive_timeout。而且您无法将其放在upsream内,请在httpserverlocation内使用。

答案 1 :(得分:0)

选项“keepalive”由keepalive module提供。由于1.1.4 keepalive功能包含在主代码中。