node.js - Nginx 和 node.js 未知指令

标签 node.js nginx configuration http-proxy

我正在尝试为 nginx 编写配置文件,但出现此错误:

unknown directive "proxy_http_version" in /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;
    }
 }

最佳答案

更新 nginx!在 NGINX 1.1.4 版本中添加了 proxy_http_version 特性

关于node.js - Nginx 和 node.js 未知指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24499135/

相关文章:

java - 配置Equinox修改 "local bundle cache"的管理

ssl - 带有 OpenSSL 1.0.2 的最新 Nginx 仍然无法提供 http/2

javascript - settimeout 阻塞事件循环 Nodejs 检查下一个示例 :

node.js - 如何打开控制台与 Express 应用交互?

mysql - Magento 在查询删除 50000 个产品时失去与 mysql 服务器的连接

linux - 为什么 linux 路由配置在两个 NIC 冗余(主/辅)时失败?

javascript - 如何模拟 "Focus"和 "typing"事件

javascript - 在sql查询结果中添加新行

linux - Docker——几个容器

nginx - 如何在 terraform 中创建 nginx 入口 - aks