Back

"redirect uri mismatch" Google Auth self hosted not using https as redirect uri

  • 1
  • Self Hosted
  • Auth
  • Web
Tobi696
21 Jul, 2024, 08:38

I am using self-hosted appwrite, running on http on a custom port (8000). Then, I am using Caddy as reverse proxy to map my subdomain appwrite.domain.com to port 8000 and Caddy manages the TLS certificates. HTTPS works correctly on the admin panel. As you can see in screenshot 1, admin panel tells me to use https for my redirect uri. However, when I try to create an oauth session, I get the error redirect_uri_mismatch (Screenshot 2) As you can see in Screenshot 3, it tries using the URI with http instead of https.

How can I fix this?

TL;DR
Developers are discussing issues related to redirect URI mismatch in Google Auth self-hosted, not using HTTPS as redirect URI. Suggestions include checking port forwarding settings, clearing app storage in Dev tools, restarting Docker containers, and modifying Caddy configurations. The problem seems to be related to Appwrite generating redirect URIs based on whether it was initiated on HTTP or HTTPS ports. Running into errors like project_provider_disabled and too many redirects, developers are troubleshooting by adjusting environment variables, removing certificates, and changing domain configurations. The solution may involve setting up a separate sub-domain or using a proxy server with valid SSL certificates in front of Appwrite to overcome TLS
Tobi696
21 Jul, 2024, 16:44

When I set tls_insecure_skip_verify, I get "404 page not found" again.

Tobi696
21 Jul, 2024, 16:46

But why would I set tls_insecure_skip_verify? After settings my app domain to localhost, I was actually relying on caddy for https on domain level, am I wrong?

bad_advice
21 Jul, 2024, 19:04

I am not a Caddy user but my understanding is that it stops Caddy from requiring a valid certificate on your upstream server (appwrite).

Tobi696
21 Jul, 2024, 19:23

Yes but I have my domain "appwrite.abc.com" and I have appwrite configured with APP_DOMAIN=localhost, so some service has to generate the TLS certificate for "appwrite.abc.com", that's Caddy in my case that's why I don't think setting tls_insecure_skip_verify would do any good

Jamy
21 Jul, 2024, 19:42

Have you checked if in the env., the parameter _APP_OPTIONS_FORCE_HTTPS is enabled ?

Tobi696
21 Jul, 2024, 20:24

no it was disabled, but now I get ERR_TOO_MANY_REDIRECTS

Jamy
21 Jul, 2024, 20:31

I'm facing the same issue, trying to investigate how to solve it on my side too. Only difference : I'm using Cloudflare

Jamy
21 Jul, 2024, 20:31
Tobi696
21 Jul, 2024, 20:31
Jamy
21 Jul, 2024, 20:36

Now I have Error 412: project_provider_disabled, even if the provider (Google) is enable in the console. Feel I'm going backward 😂 Good luck!

Tobi696
21 Jul, 2024, 20:44

But you're running appwrite on ports 80 and 443, aren't you?

Jamy
21 Jul, 2024, 20:46

Yes

Jamy
21 Jul, 2024, 20:47

I check documentation, _APP_OPTIONS_FORCE_HTTPS is used only for 80 & 443 default port. So probably not solving your problem

bad_advice
21 Jul, 2024, 21:06

@Jamy I had the provider disabled error in appwrite after testing out the changing port in my reverse proxy to 80 and then back to 443. I did this to verify that appwrite's redirect URL was being generated according to which port it was being accessed by from the original issue in this thread. I believe I had to docker compose down and then docker compose up -d --remove-orphans Not sure if the removing orphans helped but that ended up resolving my issue. I am also using Cloudflare as well.

bad_advice
21 Jul, 2024, 21:11

@Tobi696 regardless of whether you use 80 & 443, 8000 & 8443, etc. My tests show that the redirect URI is generated based on whether it was initiated on appwrite's HTTP port or HTTPS port. When you have your proxy pointing at the HTTP port it is going to generate an HTTP redirect according to my testing.

Back to the Caddy TLS insecure - Caddy still terminates the SSL for anything that is being proxied through Caddy so communication between client and caddy is encrypted. My understanding is that tls_insecure_skip_verify allows Caddy to proxy to an "insecure"/"invalid"/"self-signed" etc certificate. The data is still encrypted between Caddy and Appwrite, it just isn't with a publicly trusted certificate.

Jamy
21 Jul, 2024, 21:44

Thanks for your reply, don't want to spam here about my problem, sorry. I did what you suggested, but still the same issue :/ Tried also to disable/enable, and disable -> restart docker -> enable..

bad_advice
21 Jul, 2024, 21:48

What client are you using to test with?

Jamy
21 Jul, 2024, 21:51

Not sure to understand. I'm using Flutter, on Android emulator. I will open a new thread, and let focus here about @Tobi696 issue

bad_advice
21 Jul, 2024, 21:51

I ask because I think I had to clear app storage in Dev tools I think it was for flutter web or close all the way out and rebuild the app

Tobi696
22 Jul, 2024, 06:49

Yeah if only I got it to work using the https port 🙈

bad_advice
22 Jul, 2024, 08:30

How about trying to disable the port 80 forward on your firewall to force cloudflare to use 443?

Tobi696
22 Jul, 2024, 08:33

I'm not using cloudflare

D5
22 Jul, 2024, 08:59

Do you can DM me the redirect URL?

D5
22 Jul, 2024, 09:00

What's the appwrite version you're using?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more