Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Double Redirect - https to http with trailing slashes #103

Closed
mansona opened this issue May 25, 2018 · 11 comments · Fixed by ButterCMS/gatsbyjs-starter-buttercms#49
Closed

Comments

@mansona
Copy link

mansona commented May 25, 2018

Hey folks 👋

I'm using this static build pack with https_only turned on. Our app is predominantly a set of index.html files in folders so that we can access them like this: https://example.com/post/a-lovely-blog-post/ which would then serve /post/a-lovely-blog-post/index.html as expected.

The problem is that when you navigate to https://example.com/post/a-lovely-blog-post (no trailing slash) it then redirects you to http://example.com/post/a-lovely-blog-post/ (trailing slash but http) which then redirects you again to https://example.com/post/a-lovely-blog-post/ (trailing slash and https) because of https_only

I can't quite track exactly where that intermediate 301 redirect is coming from (the one that adds the trailing slash but removes https). If someone could point me in the right direction I would be happy to introduce a PR to fix it 👍

@herrbuerger
Copy link

Sorry to dig this up, but we have the exact same problem currently. I was wondering if you have figured out how to solve this?

@mansona
Copy link
Author

mansona commented Apr 10, 2019

@herrbuerger this is one of two issues that I have open with Heroku and neither of them have had responses in over a year 😞 One of which actually has a PR that fixes the issue.

My only recommendation for you would be to look at alternative hosting possibilities. I have moved all my static stuff onto Netlify since none of the static buildpack issues seem to be getting any love

@herrbuerger
Copy link

@mansona thanks for the quick response.

I've spend some hours looking into that and the only thing that came up which might solve the problem is a new directive in later nginx versions absolute_redirect off; (see this).

But the nginx version used in the buildpack is ancient, so I'm currently evaluating if it makes sense for us to update it, though it's probably wiser to go directly with the nginx buildpack.

Big fan of Netlify and I'd move instantly if that was a possibility (which it isn't :()

@FaridSafi
Copy link

+1

1 similar comment
@emrecan-s
Copy link

+1

@cyrilchapon
Copy link

cyrilchapon commented Mar 13, 2020

Actually; I just discovered there is a much simpler issue.

https://a.com/b (without slash, with ssl)
redirects to
http://a.com/b/ (with slash, without ssl)
by default

The third redirection is caused by https_only: true indeed.

The "double redirect" is annoying indeed, but it's only an incidence of the main issue : The first automatic redirection is mandatory (no config to disable it), pretty annoying, and also so opiniated...

EDIT: And one should add "Opiniated" yes, but furthermore non-standard opinion.
A trailing slash after a host is a RFC; a trailing slash after a directory is nothing but an opinion

@holm
Copy link

holm commented Nov 30, 2020

This was confusing me today. It's very unfortunate that we need a redirect for all page loads.

@mikekreeki
Copy link

Same issue here, just noticed it, not very cool.

@holm
Copy link

holm commented Jun 27, 2021

This should be fixed by the change in #215. Would be nice to get merged.

thesauri added a commit to Teknologforeningen/vision.tf.fi that referenced this issue Jan 12, 2022
…rects

This fix is experimental, to say the least. It assumes this pull
request to be present:

heroku/heroku-buildpack-static@6798b79

This solution is based on the following converstation:

heroku/heroku-buildpack-static#103

For this reason, I created a fork of the latest version of Heroku's
buildpack that includes the commit from the aforementioned PR:

https://github.com/thesauri/heroku-buildpack-static
@thesauri
Copy link

thesauri commented Jan 12, 2022

I encountered a similar issue for a host residing behind an nginx redirect. When visiting subdomains such as https://site.domain.foo/subpage, the user was redirected to http://site.herokuapp.com/subpage, and then to http://site.herokuapp.com/subpage/. In other words, the user was redirected away from site.domain.foo to the herokuapp domain.

I managed to solve this issue by using #215, so I would appreciate it being merged too (assuming there is no other way to do this that is more correct).

@edmorley
Copy link
Member

edmorley commented Jun 9, 2022

Hi

This buildpack is now deprecated and we are recommending people move the more actively maintained heroku-buildpack-nginx. For migration advice see here.

As such, I'm closing this issue out since we won't be making further changes to this buildpack.

@edmorley edmorley closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants