So I'm using OmniAuth with the GitHub strategy to handle user authentication for my project. When accessing the Rails server directly, everything works as it should. I recently set up Nginx to handle proxying between my development frontend and backend servers. Now when I visit /auth/github
, OmniAuth fires off the request to GitHub, but then fails on the callback with:
Started GET "/auth/github/callback?error=redirect_uri_mismatch" for 127.0.0.1 at 2014-01-22 11:54:35 -0800
I, [2014-01-22T11:54:35.365773 #13656] INFO -- omniauth: (github) Callback phase initiated.
E, [2014-01-22T11:54:35.366091 #13656] ERROR -- omniauth: (github) Authentication failure! redirect_uri_mismatch: OmniAuth::Strategies::OAuth2::CallbackError, redirect_uri_mismatch
E, [2014-01-22T11:54:35.366149 #13656] ERROR -- omniauth: (github) Authentication failure! invalid_credentials: OmniAuth::Strategies::OAuth2::CallbackError, redirect_uri_mismatch
I have set the callback URL in my application's settings on GitHub to the correct URL and it's obviously making the request properly, just with this mysterious redirect_uri_mismatch
.
Here's my Nginx server block:
server {
listen 8080;
server_name localhost;
location / {
proxy_pass http://localhost:9000;
}
location /api/ {
proxy_pass http://localhost:3000;
}
location /auth/ {
proxy_pass http://localhost:3000;
}
}
I can't really see any good reason why this shouldn't be working, though I am a relative noob to configuring Nginx.