openresty / openresty/lua-nginx-module

image_filter module with ngx.location.capture problem

Open
#1,063 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
11.8k
Forks
2.1k
Avg merge
6h 1m
Merged PRs (30d)
6

Description

I'm trying to get image width and height information. I can do it directly by querying the proxied location with curl, but I can not do it from lua code with ngx.location.capture. it just returns the image without image_filter processing:

The config

load_module "modules/ngx_http_image_filter_module.so";
location /ttt/ {
    proxy_pass_request_headers off;
    proxy_pass https://scontent.xx.fbcdn.net/v/t1.0-1/c50.50.621.621/s50x50/601487_103890943140684_608897883_n.jpg?oh=04ba29ad280bf84ed80029ce8f384ff9&oe=59488366;
    image_filter size;
}

location /test3/ {
	content_by_lua_block {
		local url = "/ttt/"
		res = ngx.location.capture(url)
		ngx.say(res.status)
		ngx.say(res.body)
	}
}

Direct call: success

$ curl -i -X GET 'http://127.0.0.1:82/ttt/'
HTTP/1.1 200 OK
Server: openresty/1.11.2.2
Date: Sun, 07 May 2017 20:00:41 GMT
Content-Type: application/json
Content-Length: 59
Connection: keep-alive

{ "img" : { "width": 50, "height": 50, "type": "jpeg" } }

Indirect call: failure

$ curl -i -X GET 'http://127.0.0.1:82/test3/'
HTTP/1.1 200 OK
Server: openresty/1.11.2.2
Date: Sun, 07 May 2017 20:00:44 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type

200
����JFIF���Photoshop 3.08BIM
a lot of data there also ...

Can you please point me how to make it work from ngx.location.capture?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the /ttt/ location's direct image_filter response with the /test3/ content_by_lua_block call to ngx.location.capture. Trace how image_filter behaves for subrequests and define done as making the captured response expose the processed image metadata rather than the raw image body.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, nginx
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.