添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

naidilepn

Hi,

I'm setting the ngx variable inside content by lua block but the updated value is not available outside.


set $varEx ' '
content_by_lua_block {
ngx.var.varEx = "someNewValue"
}
proxy_set_header $xxx $varEx
proxy_pass


I want to use the updated value to pass as header before proxy_pass.
Same is working with capture, but the api response is large. So have to avoid capture.
Please suggest.

Thanks.


naidilepn

Any other way to access variables across with good performance would be of great help.

On Monday, 22 July 2019 17:33:46 UTC+5:30, DevX wrote:
Hi,

I'm setting the ngx variable inside content by lua block but the updated value is not available outside.


set $varEx ' '
content_by_lua_block {
ngx.var.varEx = "someNewValue"
}
proxy_set_header $xxx $varEx
proxy_pass


I want to use the updated value to pass as header before proxy_pass.
Same is working with capture, but the api response is large. So have to avoid capture.
Please suggest.

Thanks.


mikejnoe

Is it due to the missing semicolons?  I’m doing the same thing with content_by_lua_file and it definitely works.


On Jul 22, 2019, at 8:03 AM, DevX < [email protected] > wrote:

Hi,

I'm setting the ngx variable inside content by lua block but the updated value is not available outside.


set $varEx ' '
content_by_lua_block {
ngx.var.varEx = "someNewValue"
}
proxy_set_header $xxx $varEx
proxy_pass


I want to use the updated value to pass as header before proxy_pass.
Same is working with capture, but the api response is large. So have to avoid capture.
Please suggest.

Thanks.



gunigovski

...use set_by_lua_block or access_by_lua_block - proxy_pass and content_by_lua_block are on the same req processing step...

...you cam also use ngx.req.set_header() instead of proxy_set_header - it would make code cleaner...

On Monday, July 22, 2019 at 8:03:46 AM UTC-4, DevX wrote:
Hi,

I'm setting the ngx variable inside content by lua block but the updated value is not available outside.


set $varEx ' '
content_by_lua_block {
ngx.var.varEx = "someNewValue"
}
proxy_set_header $xxx $varEx
proxy_pass


I want to use the updated value to pass as header before proxy_pass.
Same is working with capture, but the api response is large. So have to avoid capture.
Please suggest.

Thanks.


naidilepn

Thanks for the info.

We can set header using ngx.req.set_header() and ngx.var.http_headerName . Which one is better ?



On Monday, 22 July 2019 19:14:43 UTC+5:30, Gene Unigovski wrote:
...use set_by_lua_block or access_by_lua_block - proxy_pass and content_by_lua_block are on the same req processing step...

...you cam also use ngx.req.set_header() instead of proxy_set_header - it would make code cleaner...

On Monday, July 22, 2019 at 8:03:46 AM UTC-4, DevX wrote:
Hi,

I'm setting the ngx variable inside content by lua block but the updated value is not available outside.


set $varEx ' '
content_by_lua_block {
ngx.var.varEx = "someNewValue"
}
proxy_set_header $xxx $varEx
proxy_pass


I want to use the updated value to pass as header before proxy_pass.
Same is working with capture, but the api response is large. So have to avoid capture.
Please suggest.

Thanks.


gunigovski

...these two are different ...I would suggest to use ngx.req.set_header() - especially in case if you are planning to proxy_pass request to upstream...

On Tuesday, July 23, 2019 at 1:58:54 AM UTC-4, DevX wrote:
Thanks for the info.

We can set header using ngx.req.set_header() and ngx.var.http_headerName . Which one is better ?



On Monday, 22 July 2019 19:14:43 UTC+5:30, Gene Unigovski wrote:
...use set_by_lua_block or access_by_lua_block - proxy_pass and content_by_lua_block are on the same req processing step...

...you cam also use ngx.req.set_header() instead of proxy_set_header - it would make code cleaner...

On Monday, July 22, 2019 at 8:03:46 AM UTC-4, DevX wrote:
Hi,

I'm setting the ngx variable inside content by lua block but the updated value is not available outside.


set $varEx ' '
content_by_lua_block {
ngx.var.varEx = "someNewValue"
}
proxy_set_header $xxx $varEx
proxy_pass


I want to use the updated value to pass as header before proxy_pass.
Same is working with capture, but the api response is large. So have to avoid capture.
Please suggest.

Thanks.


naidilepn

Cool thanks.

On Tuesday, 23 July 2019 18:10:58 UTC+5:30, Gene Unigovski wrote:
...these two are different ...I would suggest to use ngx.req.set_header() - especially in case if you are planning to proxy_pass request to upstream...

On Tuesday, July 23, 2019 at 1:58:54 AM UTC-4, DevX wrote:
Thanks for the info.

We can set header using ngx.req.set_header() and ngx.var.http_headerName . Which one is better ?



On Monday, 22 July 2019 19:14:43 UTC+5:30, Gene Unigovski wrote:
...use set_by_lua_block or access_by_lua_block - proxy_pass and content_by_lua_block are on the same req processing step...

...you cam also use ngx.req.set_header() instead of proxy_set_header - it would make code cleaner...

On Monday, July 22, 2019 at 8:03:46 AM UTC-4, DevX wrote:
Hi,

I'm setting the ngx variable inside content by lua block but the updated value is not available outside.


set $varEx ' '
content_by_lua_block {
ngx.var.varEx = "someNewValue"
}
proxy_set_header $xxx $varEx
proxy_pass


I want to use the updated value to pass as header before proxy_pass.
Same is working with capture, but the api response is large. So have to avoid capture.
Please suggest.

Thanks.