-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
> Hello
Yes I was able to get it working using lua-nginx-module to rewrite the request.
If your Postgrest API server is on
http://localhost:3000and your Nginx Proxy is onhttp://localhost:3001, you can use this nginx proxy config and make request to your nginx proxy with a cookieaccess_tokenthat contains the jwt (it rewrites the headers to include aAuthorization: Bearer <jwt>header:server { listen 0.0.0.0:3001; location / { rewrite_by_lua_block { local cookie_value = ngx.req.get_headers()["Cookie"] if cookie_value ~= nil then local jwt = cookie_value:match("access_token=([^ ]+)") ngx.req.set_header("Authorization", "Bearer " .. jwt) end ngx.req.clear_header("Cookie") } proxy_pass http://0.0.0.0:3000; } }Actual request (to nginx proxy by the client):
GET HTTP/1.1 Host: localhost:3001 Cookie: access_token=mah.osum.tokenRequest relayed to Postgrest:
GET HTTP/1.1 Host: localhost:3000 Authorization: Bearer mah.osum.tokenNote that the regex used to extract the
access_tokenonly works correctly when there is a single cookie.
Metadata
Metadata
Assignees
Labels
No labels