zoukankan      html  css  js  c++  java
  • nginx集群报错“upstream”directive is not allow here 错误

    nginx集群报错“upstream”directive is not allow here 错误

    搭建了一个服务器, 采用的是nginx + apache(多个) + php + mysql(两个) 多个apache负载均衡及后端mysql读写分离的服务器.  

    当然如果网站流量小的话 就完全没有必要了! 一是搭建起来麻烦,二也增加了维护成本! 当你网站流量达到一定级别不考虑也得考虑了.

    当设定好 upstream 如下:

    upstream backend  {  server backend1.example.com weight=5;  server backend2.example.com:8080;  server unix:/tmp/backend3;}

    执行命令:/usr/local/nginx/sbin/nginx -s reload 时 报错如下:

    [emerg]: "upstream" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:52

    后来检查了一下原来是upstream backend 位置放错了, upstream位置应该放在http模块里面 但必须是在server模块的外面. 应该是下面这样的结构:

    http{upstream backend  {  server backend1.example.com weight=5;  server backend2.example.com:8080;  server unix:/tmp/backend3;}   server {  location / {    proxy_pass  http://backend;  }}}

    如果你配置的服务器也如类似的错误 不妨检查你的upstream位置是否正确!

  • 相关阅读:
    BZOJ 2752: [HAOI2012]高速公路(road)
    codevs 1979 第K个数
    洛谷 P2680 运输计划
    hdu 3501 Calculation 2
    POJ 2417 Discrete Logging
    比较数组和字典
    js事件之event.preventDefault()与event.stopPropagation()用法区别
    alert
    js基本类型的包装对象
    js取自定义data属性
  • 原文地址:https://www.cnblogs.com/justuntil/p/5538346.html
Copyright © 2011-2022 走看看