Nginx& node.js未知指令

时间:2014-06-30 21:22:20

标签: node.js nginx configuration http-proxy

我试图为nginx编写配置文件,我收到此错误:

  

未知指令" proxy_http_version"在/etc/nginx/conf.d/mydomain.conf:24

配置文件位置: /etc/nginx/conf.d/mydomain.conf

Nginx版本:我安装了nginx / 1.0.15。

这是我的配置文件。请帮我解决这个问题。

upstream node_app {
    server 127.0.0.1:3000;
    server 127.0.0.1:3001;
}

server {
    listen 80;
    server_name mydomain.com;

    # !!! handle static content requests and serve with nginx !!! #
    location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$ {
        root        /var/www/html/mydomain.com/public/;
    }

    # !!! handle dynamic content requests and serve with node defined in upstream node_app object. !!! #
    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://node_app;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
 }

1 个答案:

答案 0 :(得分:13)

更新nginx!在NGINX版本1.1.4中添加了proxy_http_version功能