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

req.subrequest() there is no way to specify/override HTTP headers #13

Closed
drsm opened this issue May 8, 2018 · 2 comments
Closed

req.subrequest() there is no way to specify/override HTTP headers #13

drsm opened this issue May 8, 2018 · 2 comments

Comments

@drsm
Copy link
Contributor

drsm commented May 8, 2018

    location = /check {
        internal;
        proxy_set_header Accept-Encoding '';
        proxy_set_header Content-Type 'application/x-www-form-urlencoded';
        proxy_pass https://www.google.com/recaptcha/api/siteverify;
    }

while proxying i can solve this, but if a subrequest hits a js_content location there is no way.

@xeioex
Copy link
Contributor

xeioex commented May 9, 2018

do you mean to specify/override HTTP headers of req.subrequest()?

You are expected to configure the desired request headers in a sub location.

This is pretty similar to what lua module does:
https://github.com/openresty/lua-nginx-module#ngxlocationcapture
Note that subrequests issued by ngx.location.capture inherit all the request headers of the current request by default and that this may have unexpected side effects on the subrequest responses. For example, when using the standard ngx_proxy module to serve subrequests, an "Accept-Encoding: gzip" header in the main request may result in gzipped responses that cannot be handled properly in Lua code. Original request headers should be ignored by setting proxy_pass_request_headers to off in subrequest locations.

You can find a more elaborate example of req.subrequest() here: https://github.com/nginxinc/nginx-openid-connect/blob/master/openid_connect.server_conf#L35

@drsm
Copy link
Contributor Author

drsm commented May 9, 2018

@xeioex thank you! now it is clear how it works.

yes i mean the subrequest's headers.
the intent was to keep a subrequest creation logic in one place, actually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants