Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ngx.req.set_uri from :access does not work on master as it does on 0.10.3 #2779

Closed
nguse opened this issue Aug 5, 2017 · 1 comment

Comments

@nguse
Copy link

nguse commented Aug 5, 2017

Summary

I wrote a plugin for Kong to do URL Rewriting and noticed that testing against 0.10.3 is behaving as expected, but when using code from master it does not work properly.

Using ngx.req.set_uri on 0.10.3 results in the URL being changed before the request is made upstream. On master, using ngx.req.set_uri results in no change made to the request before being proxied upstream.

I made a simplified plugin as an example to show the problem:
https://github.com/nguse/kong-plugin-test

This example has a test that sets up an api, test1.com -> mockbin.com (same as the example plugin) and registers the plugin. The test then makes a request to /request/foo. The plugin simply runs ngx.req.set_uri("/request/bar"). In 0.10.3, the response shows that I get mockbin.com/request/bar, but when running the test on master, it says the request was to mockbin.com/request/foo.

Steps To Reproduce

  1. Run test using kong-vagrant on https://github.com/nguse/kong-plugin-test
@thibaultcha
Copy link
Member

thibaultcha commented Aug 5, 2017

Hi,

master contains the following commit: 0010bce which improves the transparency of proxyed URIs (see the related test in the commit). It is a change targeted for 0.11, and the consequences for plugins developers are documented in the Changelog: https://github.com/Mashape/kong/blob/release/0.11/CHANGELOG.md#changed-1

The upstream URI is now determined via the Nginx $upstream_uri variable. Custom plugins using the ngx.req.set_uri() API will not be taken into consideration anymore. One must now set the ngx.var.upstream_uri variable from the Lua land. #2519

We'll make sure that the upcoming 0.10.4 release does not include this change.

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

No branches or pull requests

2 participants