3

I am feeling that I have searched the complete internet and tried nearly everything to solve my problem. Now I decided to ask you and hope that there is anybody out there who is able to help me.

I have a node application running on sub2.domain.tld:3000. Now I want to proxy this application to port 80 with nginx in the way that I am able to reach the app with sub.domain.tld. But that is not the problem. I am able to reach the first site.

The problem follows by an authentification routine with OAuth-API to verify the user for the application.

When surfing to sub2.domain.tld:3000 the process works fine. But when I change the url in the configs and try to surf to sub.domain.tld the authentification process runs into an error (error=redirect_uri_mismatch&error_description=The+redirect_uri+MUST+match+the+registered+callback+URL.....).

So I guess I am making a mistake in the redirecting of the url with nginx.

I am using nginx 1.4.7 and node 0.10.26

My nginx configuration file looks like that:

server {
    listen      80;
    access_log /var/log/nginx/access_log_sub;
    server_name sub.domain.tld;

    location / {
        include proxy_params;
        proxy_pass http://IP:3000;
        proxy_set_header    Host            $http_host;
        proxy_set_header    X-Real-IP       $remote_addr;
        proxy_set_header    Client-IP       $remote_addr;
        proxy_set_header    X-Forwarded-for $remote_addr;
    }
}

But I belive OAuth is verifying sub2.domain.tld:3000 and that it gets in conflict with sub.domain.tld

I hope you are able to help me, solving this issue.

2 Answers 2

2

The error isn't coming from nginx, it's coming from your OAuth provider:

The redirect_uri parameter is optional. If left out, GitHub will redirect users to the callback URL configured in the OAuth Application settings. If provided, the redirect URL's host and port must exactly match the callback URL. The redirect URL's path must reference a subdirectory of the callback URL.

-- https://developer.github.com/v3/oauth/#redirect-urls

Sign up to request clarification or add additional context in comments.

1 Comment

awesome, change redirectURL from config, everything working perfect, thank you guy
0

This is an old question, but...

Try changing your Host header to

proxy_set_header Host $host:$server_port

This may or may not work depending on your application.

As an aside, X-Forwarded-For should include a comma-separated list of the originating client and any proxies it passes through.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.