Skip to content

Incorrect scheme in redirection when APPEND_SLASH_FOR_POSSIBLE_DIRECTORY is enabled #433

@segaq44

Description

@segaq44

Bug Overview

When nginx-s3-gateway listens over http behind a reverse proxy configured with https the redirection is incorrect.

Try to access https://<URL>/some/path
results in 302 http://<URL>/some/path/
but expected is 302 https://<URL>/some/path/

Expected Behavior

Redirect to https with the ending /

Steps to Reproduce the Bug

My deployment with Kubernetes:
User Agent --https--> NGINX Ingress Controller --http--> NGINX S3 Gateway

Config:

S3_STYLE = path
ALLOW_DIRECTORY_LIST = true
APPEND_SLASH_FOR_POSSIBLE_DIRECTORY = true

Environment Details

  • Built from master (oss / unprivileged) (01eed95)
  • Target deployment platforms : local Kubernetes
  • S3 backend implementation: Netapp StorageGrid

Additional Context

From default.conf the $scheme is retrieved directly from the request.
But retrieving it from X-Froweded-Proto seems more correct in this case.

    location @trailslash {
        # 302 to request without slashes
        # Adding a ? to the end of the replacement param in `rewrite` prevents it from
        # appending the query string.
        rewrite ^ $scheme://$http_host$uri/$is_args$query_string? redirect;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions