hamishforbes / lua-resty-upstream

Upstream connection load balancing and failover module for Openresty
MIT License
117 stars 26 forks source link

How to use it ? #11

Closed bino closed 8 years ago

bino commented 9 years ago

Dear Developers

I'm sorry for my silly question.

I Have newest OpenResty installed. in sort, I (when access http://127.0.0.1:8080/pools) already got :

{"primary":{"keepalive_pool":256,"hosts":[{"host":"127.0.0.1","weight":10,"port":81,"id":"1","healthcheck":{"last_check":1447815898.606,"interval":60},"failcount":0,"up":true,"lastfail":0},{"host":"127.0.0.1","weight":10,"lastfail":0,"id":"2","healthcheck":{"last_check":1447815898.606,"interval":60},"failcount":0,"up":true,"port":82}],"up":true,"read_timeout":10000,"method":"round_robin","failed_timeout":60,"timeout":100,"keepalive_timeout":120000,"priority":0,"max_fails":3}}

Note : I striped out all ssl parts.

for port 80, I have :

    server {
        listen 80;
        server_name lua-load-balancer;

        location / {
            content_by_lua_file /usr/local/openresty/nginx/html/lua-load-balancer.lua;
        }
    }

yes I copied lua-load-balancer.lua to that directory and chmod +x.

But when I access http://127.0.0.1 , I got 404

Kindly please give me any enlightenment.

Sincerely -bino-

hamishforbes commented 9 years ago

I'd suggest you set the nginx/openresty error log to debug level and have a look in there. I believe content_by_lua_file will return a 404 if it can't load the file so that could be it.

Also you shouldn't chmod +x the Lua file, it doesn't need to be executable just readable by openresty.

bino commented 9 years ago

Thankyou for your fast response. I'll take a look into it.

Sincerely -bino-