Skip to content

Conversation

@lonerr
Copy link
Contributor

@lonerr lonerr commented Nov 25, 2018

I hope this should solve the following collision:

server {
    listen 80;
    include /etc/nginx/a/proxy.conf;
    include /etc/nginx/b/proxy.conf;
}

Where /etc/nginx/a/proxy.conf is

location /a/ {
    content_by_lua_block { ngx.say("/a/ is called") }
}

and /etc/nginx/b/proxy.conf is

location /b/ {
    content_by_lua_block { ngx.say("/b/ is called") }
}

I hereby granted the copyright of the changes in this pull request
to the authors of this lua-nginx-module project.

@felixcolaci
Copy link

Hi Guys,
thank you for your great work on the open resty project. It's really helpful to be able to integrate lua with nginx.
Never the less we are experiencing serious trouble with this issue in production right now. Can you give us any hint on when this issue will be resolved and integrated?
Kind regards & keep up the great work!
Felix

@agentzh
Copy link
Member

agentzh commented Feb 4, 2019

@lonerr Are you seeing that all the travis ci jobs are failing horribly in this PR?

https://travis-ci.org/openresty/lua-nginx-module/builds/459270635?utm_source=github_status&utm_medium=notification

I'm not sure what problem this PR tries to address. The *_by_lua_block directives do not involve any Lua source file paths anyway.

@lonerr
Copy link
Contributor Author

lonerr commented Feb 4, 2019

@agentzh yes, I saw. But it seems that all these travis errors are about changed format of error log messages. As for the problem itself, please have a look at the simplest test case below:

/etc/nginx/nginx.conf

user  nginx;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;

load_module modules/ndk_http_module-debug.so;
load_module modules/ngx_http_lua_module-debug.so;

events {}

http {
    access_log /var/log/nginx/access.log;
    server {
        listen 80;
        include /etc/nginx/a/proxy.conf;
        include /etc/nginx/b/proxy.conf;
    }
}

/etc/nginx/a/proxy.conf

location /a/ {
    content_by_lua_block { ngx.say("/a/ is called") }
}

/etc/nginx/b/proxy.conf

location /b/ {
  content_by_lua_block { ngx.say("/b/ is called") }
}

The results are unexpectedly incorrect:

% curl http://ubuntu-18.04.stand/a/
/a/ is called

% curl http://ubuntu-18.04.stand/b/
/a/ is called

Adding lua_code_cache off; corrects the behavior:

% curl http://ubuntu-18.04.stand/a/
/a/ is called

% curl http://ubuntu-18.04.stand/b/
/b/ is called

Hope this helps.

agentzh added a commit that referenced this pull request Feb 5, 2019
… source checksum as part of the Lua code cache key. thanks Oleg A. Mamontov for the report in #1428.

Fix #1428.

optimize: now we exclude the current nginx config file info from the cache keys for inlined Lua code snippets in nginx config files.
@agentzh
Copy link
Member

agentzh commented Feb 5, 2019

@lonerr OK, I see what's going on here. I proposed a pull request to fix this properly. See #1469.

agentzh added a commit that referenced this pull request Feb 5, 2019
… source checksum as part of the Lua code cache key. thanks Oleg A. Mamontov for the report in #1428.

Fix #1428.
@agentzh agentzh closed this in #1469 Feb 5, 2019
thibaultcha added a commit to thibaultcha/meta-lua-nginx-module that referenced this pull request Jul 28, 2019
bugfix: inlined Lua code snippets in nginx.conf failed to use the Lua
source checksum as part of the Lua code cache key. Thanks Oleg A. Mamo
ntov for the report in openresty/lua-nginx-module#1428.

Upstream patch from agentzh.
thibaultcha added a commit to thibaultcha/meta-lua-nginx-module that referenced this pull request Jul 29, 2019
bugfix: inlined Lua code snippets in nginx.conf failed to use the Lua
source checksum as part of the Lua code cache key. Thanks Oleg A. Mamo
ntov for the report in openresty/lua-nginx-module#1428.

Upstream patch from agentzh.
thibaultcha added a commit to thibaultcha/meta-lua-nginx-module that referenced this pull request Jul 31, 2019
bugfix: inlined Lua code snippets in nginx.conf failed to use the Lua
source checksum as part of the Lua code cache key. Thanks Oleg A. Mamo
ntov for the report in openresty/lua-nginx-module#1428.

Upstream patch from agentzh.
thibaultcha added a commit to thibaultcha/meta-lua-nginx-module that referenced this pull request Jul 31, 2019
bugfix: inlined Lua code snippets in nginx.conf failed to use the Lua
source checksum as part of the Lua code cache key. Thanks Oleg A. Mamo
ntov for the report in openresty/lua-nginx-module#1428.

Upstream patch from agentzh.
thibaultcha added a commit to thibaultcha/meta-lua-nginx-module that referenced this pull request Jul 31, 2019
bugfix: inlined Lua code snippets in nginx.conf failed to use the Lua
source checksum as part of the Lua code cache key. Thanks Oleg A. Mamo
ntov for the report in openresty/lua-nginx-module#1428.

Upstream patch from agentzh.
thibaultcha added a commit to thibaultcha/meta-lua-nginx-module that referenced this pull request Jul 31, 2019
bugfix: inlined Lua code snippets in nginx.conf failed to use the Lua
source checksum as part of the Lua code cache key. Thanks Oleg A. Mamo
ntov for the report in openresty/lua-nginx-module#1428.

Upstream patch from agentzh.
thibaultcha added a commit to thibaultcha/meta-lua-nginx-module that referenced this pull request Aug 26, 2019
bugfix: inlined Lua code snippets in nginx.conf failed to use the Lua
source checksum as part of the Lua code cache key. Thanks Oleg A. Mamo
ntov for the report in openresty/lua-nginx-module#1428.

Upstream patch from agentzh.
thibaultcha added a commit to openresty/meta-lua-nginx-module that referenced this pull request Aug 27, 2019
bugfix: inlined Lua code snippets in nginx.conf failed to use the Lua
source checksum as part of the Lua code cache key. Thanks Oleg A. Mamo
ntov for the report in openresty/lua-nginx-module#1428.

Upstream patch from agentzh.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants