配置Nginx以代理两个虚拟专用服务器

时间:2014-12-27 00:51:22

标签: nginx webserver virtualhost reverse-proxy

我正在设置一个Nginx前端服务器,以便在不同的端口(例如8080和8081)上运行两个节点应用程序。我正在关注Nginx docs for configuring multiple virtual private servers,但是当我放置http {}语法时,Nginx会抛出错误。

Restarting nginx nginx
...fail!

以下是代码:

http {

# Configuration specific to HTTP and affecting all virtual servers

server {
    # configuration of virtual server 1

    location /one {
        # configuration for processing URIs with '/one'
    }

    location /two {
        # configuration for processing URIs with '/two'
    }
}

server {
    # configuration of virtual server 2
}
} 

当删除http {}时,nginx不会产生任何错误。

Restarting nginx nginx
...done

我目前正在运行nginx版本:nginx / 1.4.6(Ubuntu)。 有人可以解释为什么会这样吗?

0 个答案:

没有答案