Login via twitter/fb/google always uses "localhost:6000"


(Bersaelor) #1

I’m running discourse on a debian server, via docker etc.

Everything is working fine, I followed the standard setup to allow login via fb/twitter/google but regardless of the site, I always have the problem that:

“The redirect URI in the request: http://localhost:6000/auth/google_oauth2/callback did not match a registered redirect URI.”

I can totally use “http://localhost:6000/auth/google_oauth2/callback” as the allowed redirect url in the google/fb/twitter fields, but then the redirect obviously won’t work, since it won’t redirect to my server “forum.mysite.org”.
I installed my discourse on my server, not on the local machine, why is discourse always giving this localhost:6000-url to the third party apis?

Also when I run “discourse config --help” on my server it correctly reports:


APP_USER=discourse
APP_WIZARDS=
DATABASE_URL=postgres://***:***@127.0.0.1/discourse
DISCOURSE_DEVELOPER_EMAILS=***@***.com
DISCOURSE_HOSTNAME=forum.mysite.org
GEM_PATH=/opt/discourse/vendor/bundle/ruby/2.0.0:


(Sam Saffron) #2

Is this a docker based install?


(Bersaelor) #3

I installed it via Packages for pkgr/discourse .
It did install docker during the install process (as a package dependency), so I guess yes.


What is the best way to set the discourse hostname?
(Sam Saffron) #4

Nope packgr is a third party unsupported method try following our official install guide.


(Bersaelor) #5

Got that, but regardless of installation, which is the variable used in the auth-redirect-url? I did check through the app but couldn’t find the location/configure yml for it.


(Jeff Atwood) #6

Sorry, we just don’t have the kind of time needed to support different install methods. I apologize. Once you have a Docker based install, let us know.


(Kane York) #7

To chime in with @codinghorror - the advice I would have given you, were you running on Docker, woudl be ‘do a rebuild’. But I can’t know the environment you’re using, there’s probably something subtly wrong in a config file somewhere and I have no way of knowing that.

The reproducible environments are one hell of a boon, especially with the backup -> set up new instance -> restore procedure.


(Cyril Rohr) #8

Hi @Bersaelor,

Could you give me the output of sudo discourse config (removing any sensitive data)? Either here or email me directly at support@packager.io

Also, I’m a bit surprised by your mention of having installed docker during the process, as the package in no way depends on it (which is actually the point :smiley:).


(Danny Dulai) #9

I have the same issue, but I’m using the official docker install, and via digital ocean even.

I also have DISCOURSE_HOSTNAME: ‘community.roonlabs.com’ set in containers/app.yml

and inside the docker:

root@community-app:/# export | grep DISC declare -x DISCOURSE_DB_HOST="" declare -x DISCOURSE_DB_PORT="" declare -x DISCOURSE_DB_SOCKET="/var/run/postgresql" declare -x DISCOURSE_DEFAULT_LOCALE="en" declare -x DISCOURSE_DEVELOPER_EMAILS="REDACTED" declare -x DISCOURSE_HOSTNAME="community.roonlabs.com"

yet, facebook login is passing a callback url of localhost


(Daniel) #10

Hi @Danny_Dulai,

I have the same problem with my docker image.

how did you fixed this?

I use nginx as a proxy, but after login, the user is forwarded to https://localhost:6000/login

my nginx prox config:

location '/' {
         if ($scheme = 'http') {
                 rewrite        ^ https://$server_name$request_uri? permanent;
         }
        proxy_set_header        X-Real-IP               $remote_addr;
        proxy_set_header        X-Forwarded-For         $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Proto       https;
        proxy_pass      http://localhost:6000;
} 

best regards,
Daniel


(Daniel) #11

I have found the solution here:

i needed to add this to my nginx config:

proxy_set_header Host $http_host;

best regards,
Daniel.