Page MenuHomePhabricator

[[Special:Random]] when used in a proxied website redirects to the main domain wikipedia.org
Closed, InvalidPublic

Description

Context

Since a little more than two years, I am maintaining https://vikiansiklopedi.org, a proxy of Wikipedia in many languages first set up in response to the blockade of Wikipedia in Turkey ("vikiansiklopedi" means "wiki-encyclopedia" in Turkish).

The proxy uses Caddy server configured to pass requests to Wikipedia's servers, see the configuration template. I also proxy mobile domains.

See T232188 for additional context.

Steps to reproduce

I could reproduce this bug on multiple browsers and I have no reason to believe this is a client-related issue, nor I think this is a configuration issue of my proxy.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFri, Sep 6, 12:26 PM
Reedy added a subscriber: Reedy.Fri, Sep 6, 12:31 PM

I could reproduce this bug on multiple browsers and I have no reason to believe this is a client-related issue, nor I think this is a configuration issue of my proxy.

What does your proxy do with the Location: header? As it kinda seems like it's not capturing it and potentially just passing it through

Sams-MBP:~ reedy$ curl -I https://en.wikipedia.org/wiki/Special:Random | grep location
location: https://en.wikipedia.org/wiki/Shea_Hillenbrand
Sams-MBP:~ reedy$ curl -I https://en.vikiansiklopedi.org/wiki/Special:Random | grep location
location: https://en.wikipedia.org/wiki/KTFO-CD

So this isn't our fault if your proxy isn't dealing with it correctly and passing it through verbatim...

Reedy updated the task description. (Show Details)Fri, Sep 6, 12:37 PM

I could reproduce this bug on multiple browsers and I have no reason to believe this is a client-related issue, nor I think this is a configuration issue of my proxy.

What does your proxy do with the Location: header? As it kinda seems like it's not capturing it and potentially just passing it through

I think I don't do anything with it, as you can see from the configuration template that I am using.

Here's the detail (${lang} is the language code, e.g. en ):

proxy / https://${lang}.wikipedia.org {
    header_upstream X-Real-IP {remote}
    header_upstream X-Forwarded-Proto {scheme}
}

Do you think this is a bug of the server I am using (Caddy), or should I change something in the configuration?

Reedy added a comment.Fri, Sep 6, 1:08 PM

https://github.com/caddyserver/caddy/issues/1011 looks a lot like the issue you're experiencing

https://github.com/caddyserver/caddy/issues/1011 looks a lot like the issue you're experiencing

Thank you for the pointer.

So, in the issue above they suggest to use the preset transparent for the proxy, but I have an issue with that.

transparent is a shortcut that adds the following lines to the config:

header_upstream Host {host}
header_upstream X-Real-IP {remote}
header_upstream X-Forwarded-For {remote}
header_upstream X-Forwarded-Port {server_port}
header_upstream X-Forwarded-Proto {scheme}

I have noticed that I have a problem with the first line of the configuration because if I insert it in my configuration I get an error from Wikimedia's servers:

Domain not configured

This domain points to a Wikimedia Foundation server, but is not configured on this server.

(see screenshot below)

Without the header_upstream Host {host} line the proxy works, but I'm still experiencing the redirect issue described above.

Reedy added a comment.Sat, Sep 7, 12:17 AM

Have you considered asking Caddy for support with their software? :)

Have you considered asking Caddy for support with their software? :)

Yeah, sorry, I didn't get your initial comment:

So this isn't our fault if your proxy isn't dealing with it correctly and passing it through verbatim...

I am going to open a bug report to Caddy.

Aklapper closed this task as Invalid.Mon, Sep 9, 12:40 PM

I'm closing this task as the issue to fix currently does not look like it should or can be fixed in Wikimedia code.
Please set the status of this report back to "Open" via the Add Action...Change Status dropdown if I am wrong! Thanks a lot!

I've fixed this, it seems that Caddy implemented a directive to handle this case, here's the pull request caddy#2144.