天天看點

OpenResty 啟動失敗報錯

  1. 錯誤提示
  1. 錯誤原因

    nginx.conf 中 limit_conn_zone配置問題

  2. 解決方案
  • 将nginx.conf 中 limit_conn_zone $binary_remote_addr zone=name:10m; (注:perip是自定義名)
  • name 為perip 的配置注釋掉
  • 重新開機 openresty 即可
  1. 附上本人完整 nginx.conf
user root root;
#user  nobody;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #cache
    lua_shared_dict dis_cache 128m;
     #限流設定
    limit_req_zone $binary_remote_addr zone=contentRateLimit:10m rate=2r/s;

    #根據IP位址來限制,存儲記憶體大小10M
    limit_conn_zone $binary_remote_addr zone=addr:1m;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        #所有以brand開始的請求,通路本地changgou-service-goods微服務
        location /brand {
            limit_conn addr 2;
            proxy_pass http://192.168.0.51:18081;
        }

        location /update_content {
        content_by_lua_file /root/lua/update_content.lua;
        }

        location /read_content {
         #使用限流配置
        limit_req zone=contentRateLimit burst=4 nodelay;
        content_by_lua_file /root/lua/read_content.lua;
        }

        location / {
            #limit_conn perip 10;#單個用戶端ip與伺服器的連接配接數.
            #limit_conn perserver 100;#限制與伺服器的總連接配接數
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
            root   html;
        }
    }
}
           

繼續閱讀