S
S
Semen Frolov2020-01-24 16:19:40
Nginx
Semen Frolov, 2020-01-24 16:19:40

How to use/pass variable from lua in nginx config?

Hello!
I can’t immediately understand how to solve the following problem:
We have openresty and this is the location

location ~* \.(js|eot|svg|ttf|woff|woff2|css)$ {
        content_by_lua_file /var/www/lua/get_template_path.lua;
        root /var/www/lua/$template_path/;
}

I want to do something in the get_template_path.lua file to set the $template_path variable, but I can’t figure out how to set this variable in the lua file so that it becomes available in the nginx config (

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
anikavoi, 2020-03-21
@anikavoi

You need to do the opposite:
in nginx's conf:
set $rr_add_log ''; # this line is required to create $rr_add_log at config time
in script.lua
...
ngx.var.rr_add_log = "someone"
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question