Unwanted redirects to localhost
Closed this issue · 27 comments
I've tried to setup Accent and I think I got it somewhat right (can't know because your docs either aren't updated or just barely finished.. or both? it's just not user/developer friendly, that's something I can tell), I believe.
The problem now is, that I've setup an A record for translate.ebio.gg which points towards my server and the server is a Nginx reverse proxy. This is my configuration:
Yet, when accessing https://translate.ebio.gg, it just redirects the browser to localhost. Is there any reason why and any way for fixing this?
Accesing the localhost:4000 web server on the same machine seems to actually return data.
Hello! What’s your CANONICAL_URL
in your env var? All the necessary config are documented here: https://github.com/mirego/accent?tab=readme-ov-file#production-setup
From what I can tell you will need CANONICAL_URL=https://translate.ebio.gg
Hello there,
my CANONICAL_URL
is set to https://translate.ebio.gg
. This is my entire environment variables configuration:
Are all of the ones from https://github.com/mirego/accent?tab=readme-ov-file#production-setup fully required?
I think your env var are not loaded correctly since the log should show the full URL here:
[info] Running Accent.Endpoint with Bandit 1.1.0 at 0.0.0.0:4000 (http)
[info] Access Accent.Endpoint at https://afdh9f20-asdoh.ngrok.io
If you are statring it with docker compose, the environment is not read from the .env
file, it is declared directly in the yaml
file. This could be improved in the documentation. A PR is welcome!
Maybe also dont put https://
before the canonical url. That broke my instance
I think your env var are not loaded correctly since the log should show the full URL here:
[info] Running Accent.Endpoint with Bandit 1.1.0 at 0.0.0.0:4000 (http) [info] Access Accent.Endpoint at https://afdh9f20-asdoh.ngrok.io
If you are statring it with docker compose, the environment is not read from the
.env
file, it is declared directly in theyaml
file. This could be improved in the documentation. A PR is welcome!
Am I doing something wrong again or not? I tried to port the vars from .env to the docker-compose.yml.
![image](https://private-user-images.githubusercontent.com/60970791/287360439-61efd67b-807a-4625-9990-df233c17861f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0MzA2NDEsIm5iZiI6MTcyMDQzMDM0MSwicGF0aCI6Ii82MDk3MDc5MS8yODczNjA0MzktNjFlZmQ2N2ItODA3YS00NjI1LTk5OTAtZGYyMzNjMTc4NjFmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA4VDA5MTkwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI4YjBjYmViZDg5ZjU0MjFlNjRjODYyYjUwZGVmYWM1MDBhZGFkMjNkMDNjYmQ3ZTMzMDNiZjFmOTY5NzkyYjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Rqe79fYVO_uYANANOhl36LGPicaHmkv70tVXIn7mqfY)
![image](https://private-user-images.githubusercontent.com/60970791/287360617-07ce3847-c0dc-4817-8420-727191f72180.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0MzA2NDEsIm5iZiI6MTcyMDQzMDM0MSwicGF0aCI6Ii82MDk3MDc5MS8yODczNjA2MTctMDdjZTM4NDctYzBkYy00ODE3LTg0MjAtNzI3MTkxZjcyMTgwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA4VDA5MTkwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc0M2YxYTgxYzVlMzMxY2FjNDA5MTJjZjk0MmMwOTU3MTVlMzFjZjUwZWEzNmJjYWQ5MTZiNDQ0NDhmYmU5MzUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.4wX_ErT9EGOCiwbZiGt2em0rwjRnzwXtnlsmRkWYHw4)
@Northernside you misspellt CANONICAL
xd
oh my fucking god
...
idk what to say
😭
i don't think that this is the problem but it will solve a problem later. try to remove the https:// in the canonical url. that solved the problem for me
Yes it shows that on my machine too
But it works
By removing the https://
the canonical is invalid so it does not enforce a URL 😄 That’s why it works.
oh lmao. well if I didn't remove the https://
I would just get a too much redirects error
turns out http://
works
Yes indeed, because SSL is enforced if the canonical URI is using https
.
https://github.com/mirego/accent/blob/master/config/runtime.exs#L23
If you’re using nginx to handle the TLS stuff, the Elixir application should not be handling it too.
However, if nginx is handling the TLS termination and passing the X-Forwarded-Proto
to the Elixir application, CANONICAL_URL=https://…
should work.
https://github.com/mirego/accent/blob/master/lib/accent/endpoint.ex#L50
it passes translate.ebio.gg to server X and server X is a Nginx server which then passes it to 127.0.0.1:4000, as seen here:
127.0.0.1:4000 is Accent and it's configuration is this:
Maybe this clarifies a bit more of my current issue/situation. Do you know any way on how I can prevent it from redirecting to localhost?
Changing the CANONICAL_URL
from https://translate.ebio.gg
to http://translate.ebio.gg
does not change anything in terms of behaviour, as seen here again:
Also explicitly setting FORCE_SSL
to false
has no effect on this behaviour.
then you also have to change the https://
to http://
in the canonical url as remi said
ah i'm dumb and i can't read
dont worry!
Yeah FORCE_SSL
is documented but not used in the codebase, that’s my bad 😄
However, if nginx is handling the TLS termination and passing the
X-Forwarded-Proto
to the Elixir application,CANONICAL_URL=https://…
should work.https://github.com/mirego/accent/blob/master/lib/accent/endpoint.ex#L50
![image](https://private-user-images.githubusercontent.com/60970791/287376233-c7c983e2-f535-452e-8ba6-617d78473400.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0MzA2NDEsIm5iZiI6MTcyMDQzMDM0MSwicGF0aCI6Ii82MDk3MDc5MS8yODczNzYyMzMtYzdjOTgzZTItZjUzNS00NTJlLThiYTYtNjE3ZDc4NDczNDAwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA4VDA5MTkwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFjZDdhN2QzOGJkZWMxM2FkMzNlNDM0ZDZhZjViZTUwY2NjYjBiYTk5MDFjZGQ3ZTk3YTljMTE0YTViNWFhM2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.LueCdNMF1mghHuRyg786AvQnywkk8vBcuCbpZYVRq7Q)
Tried that, nothing changed 👀
Oh, funny thing: if I access https://translate.ebio.gg/ it returns me to https://localhost but if I access https://translate.ebio.gg/? (or any other query related input) it returns me to https://translate.ebio.gg/ AND serves the proper content. What? 😭
Oh oops nevermind, it seems like it was just a silly cache on my side!
Thank you for all your help ❤️