Skip to content

Redirect after authentication doesn't always work correctly #2603

@pcolmer

Description

@pcolmer

Describe the bug
When running yourls in a Docker container, the redirect that takes place after authentication doesn't always work. Sometimes (and I haven't been able to pin this down precisely), the redirect is to http://localhost/admin instead of the correct site URL.

As far as I can tell, this is the only place where the yourls code references $_SERVER[SERVER_NAME] rather than YOURLS_SITE. Making that code change fixes the problem.

To Reproduce

  1. Configure docker-yourls to run with YOURLS_SITE set to "http://wibble:8002" and port mapping of 8002:80.

  2. Configure Apache to listen on port 8000 and reverse-proxy to http://localhost:8002. This is deliberate because:

    a) we need Apache to be proxying here and

    b) we need Apache to listen on a non-standard port to cause the reply redirection to show as incorrect.

  3. Navigate to http://localhost:8000/admin/. Enter valid credentials.

Expected behavior
What should happen is that yourls should return a redirection header of http://wibble:8002/admin/.

Actual behavior
The redirection header is to http://localhost/admin/ instead. Note that there is no port number.

Versions
1.7.6 running inside the yourls Docker container. No extensions or plugins.

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