turbolinks / turbolinks-classic

Classic version of Turbolinks. Now deprecated in favor of Turbolinks 5.
MIT License
3.54k stars 428 forks source link

Turbolink redirects behind nginx proxy #625

Closed vevisystems closed 8 years ago

vevisystems commented 8 years ago

Hi,

We have a rails application with turbolinks enabled, behind a reverse nginx proxy which also rewrites the url (actually it adds an extra folder to the request path). That is, a request to:

http://www.example.com/whatever

gets changed into

http://www.example.com/extra/whatever

before sending it to the upstream rails server.

With regular redirects, this works pretty well thanks to nginx proxy_redirect directive. http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect

However, turbolinks adds a "non-standard" X-XHR-Redirected-To header, making the extra path go to the client and producing an invalid request from the browser.

How you deal with this kind of issues? Is there any solution available? I would prefer not having to disable turbolinks, as speed boost is quite impressive.

Thibaut commented 8 years ago

Turbolinks needs the X-XHR-Redirected-To header to update the URL in the location bar when the server performs a redirection. Without it it would use the wrong URL (the one before the redirection).

Closing the issue since this is not a Turbolinks bug. I'd recommend asking on StackOverflow.

vevisystems commented 8 years ago

While I agree it may be not a turbolink bug, it is really a problem as inverse proxies are very common in any web architecture, so in my opinion turbolinks should support it. Anyway, I will try to find a solution and suggest it here if I found one.

quentindemetz commented 7 years ago

@vevisystems any luck?

vevisystems commented 7 years ago

Not really, we had to change our implementation to avoid this problem. I don't actually remember what we needed to do, but in any case it was not a solution to this problem.