8000 sendfile with nginx/X-Accel-Redirect % or ? character encoding issue · Issue #1306 · rack/rack · GitHub
[go: up one dir, main page]

Skip to content
sendfile with nginx/X-Accel-Redirect % or ? character encoding issue #1306
@dup2

Description

@dup2

Using nginx with X-Accel-Redirect as documented within lib/rack/sendfile.rb does not seem to work for files which contain a % or ? character in their name.

How to reproduce:

  • Setup nginx with a location and X-Accel-Mapping as documented to allow sending files from /data/
  • Create a file /data/sample/Report90%.pdf
  • Trigger sendfile with the proper headers and file location pointing to /data/sample/Report90%.pdf

Nginx will accept the internal X-Accel-Redirect request but fail to read the file /data/sample/Report90%.pdf and return a 404 error to the client. This does not happen when the % is removed from the file name.

We tried to replace the % character with %25 (and therefore triggering X-Accel-Mapping with a path of /data/sample/Report90%25.pdf) which seems to work.

According to the changelog of nginx as of 2014 for version 1.5.9: now nginx expects escaped URIs in "X-Accel-Redirect" headers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0