2013-04-30 87 views
1

我使用下面的配置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 /啓用站點-/ site.conf,當我重新啓動nginx的它給了我下面的錯誤:

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

回答

2

沒有keepalive指令。改爲使用keepalive_timeout。你不能把它放在upsream裏面,在http,serverlocation裏面使用。

+0

謝謝!它仍然存在於nginx網站上。 – user2117190 2013-04-30 17:00:55

0

選項「keepalive」由keepalive module提供。而且從1.1.4開始,keepalive功能被包含在主代碼中。

+0

您正在混合兩件事 - 該模塊正在配置keepalive以連接到上游代理,而不是來自客戶端的傳入連接。 – Marki555 2014-01-30 10:16:10