2

I have an issue with attempting to utilize ngx on any of the lua coding in ZeroBrane Studio, including resty.cookie. Am I doing something wrong? (This is in Windows)

I have OpenResty downloaded, but I have no idea how to compile the ngx inside despite looking at multiple instructions on how to do so, as all of the attempt made on debugging always results in "attempt to index global 'ngx' (a nil value)".

EDIT: To rephrase, I am using ZeroBrane Studios, OpenResty and StrawberryPerl. I am trying to utilize resty.cookie that I had downloaded via LuaRocks to pull a cookie from a certain site (httpbin.org). However, I noticed that whenever I run the debugger, it ends up with "attempt to index global 'ngx' (a nil value)" at the "require resty.cookie" line. I decided to look at the guide that was shown in the website. It showed the same thing, so I have no idea how to fix this issue.

6
  • Can you elaborate more on what you're doing? Commented Jan 23, 2019 at 6:40
  • I am trying to get the cookie from a specific site using "Zerobrane Studio". However, every time I tried to use "ngx" (For example, "local cookie_value = ngx.var.cookie_2"), it automatically resulted in the specified error. Commented Jan 23, 2019 at 6:52
  • Do you follow these instructions ? Commented Jan 23, 2019 at 7:49
  • Yes I did. However, at the point where I was supposed to create content.lua, the error appeared with "attempt to index global 'ngx' (a nil value)" at second line whenever I execute the debug. Commented Jan 23, 2019 at 7:50
  • Updated the main question to be more precise. Commented Jan 24, 2019 at 10:57

1 Answer 1

1

I think you mistakenly believe that openresty is some sort of Lua library that lets you do HTTP stuff. It's not. Nginx is a web server and OpenResty is just a modified version of it that lets you generate your websites dynamically using Lua.

If you want to communicate over HTTP from within plain Lua, you need something different (like Luasocket or LuaHTTP).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.