Discouse passes localhost uri as oauth redirect_uri

AI-generated summary

A user, marijn, encountered an issue with OAuth via GitHub and Twitter in their Docker-based Discourse install, resulting in a message=redirect_uri_mismatch error. The problem was caused by Discourse passing a localhost URI as the redirect_uri. riking suggested that the issue might be due to missing configuration lines in the nginx proxy setup. marijn confirmed that adding the recommended lines to their nginx config solved the problem.

I’ve set up what should be a vanilla Docker-based Discourse install (except that I’ve imported an existing database from another, non-Docker install). Things mostly work, but OAuth via github (as well as twitter) fails with a message=redirect_uri_mismatch error. Inspecting the actual packets that are being sent over, I see this in the url:

redirect_uri=http%3A%2F%2Flocalhost%3A6080%2Fauth%2Fgithub%2Fcallback

So that explains that error message. What can I do to make Discourse use its real url (discuss.codemirror.net in this case)?

Edit: Forgot to mention, the container isn’t directly binding port 80/443, but being proxied through an nginx, since the host serves other sites as well.

What is your container config?

Did you forget this part of the nginx config?

Thanks! I was missing the extra nginx config lines, adding those solved the issue.