0

My Rails app used to use OmniAuth to login in through Facebook/Twitter/Google accounts (different omniauth gems). Everything was working when my app was in some server which was preconfigured, but which I couldn't configure. Now I'm establishing my app in DigitalOcean and process of logging-in works only to some moment.

When I try to log in (with Google account) I receive following feedback:

  1. That’s an error.

Error: redirect_uri_mismatch

The redirect URI in the request, https://name_of_my_domain.com:80/auth/google_oauth2/callback, does not match the ones authorized for the OAuth client

I've noticed something what wasn't in "old" server - an url contains port 80 after my name of domain. Example:

https://name_of_my_app.com:80/auth/google_oauth2/callback?state=...and_so_on

The same :80 appears also for Facebook and Twitter url. I really believe that :80 is unnecessary, but I have no idea how to turn it off.

So then I tried to make a workaround and I added to "Authorised redirect URIs" in Google developers api:

Authorised redirect URIs:

https://name_of_my_app.com:80/auth/google_oauth2/callback

So then I tried once again, I chose a Google Account to use and as a result I received following information from my browser:

This site can’t provide a secure connection name_of_my_app.com sent an invalid response.

Try running Windows Network Diagnostics.

ERR_SSL_PROTOCOL_ERROR

Nginx error log is silent about any errors.

But, just in case, I provide my NGINX site configuration (/etc/nginx/sites-available/rails):

server {
    listen 80;
    root /home/rails/model_app/public;
    server_name name_of_my_domain.com;
    index index.htm index.html;

        location ~ /.well-known {
                allow all;
        }

        location / {
                proxy_pass http://localhost:3000;

                proxy_set_header  Host $host;
                proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header  X-Forwarded-Proto $scheme;

                proxy_set_header  X-Forwarded-Ssl on;
                proxy_set_header  X-Forwarded-Port $server_port;
                proxy_set_header  X-Forwarded-Host $host;
        }
}

File /etc/nginx/nginx.conf:

worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
}

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;

        server_names_hash_bucket_size 64;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        gzip on;

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

Off course I have a domain managed by DigitalOcean and generated Let's Encrypt certificate (whole page works well with https).

I have Load Balancer turned on, which I use for a page, where:

  • Forwarding Rules are:

HTTP on port 80 -> HTTP on port 80

HTTPS on port 443 -> HTTP on port 80

  • setting for SSL is set: Redirect HTTP to HTTPS (On).

So I think that there are two issues: one - port 80 in url, second - lack of secure connection when first problem "is solved". Any ideas how to solve both these issues?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.