ddario
ddario

Reputation: 1035

nginx loadbalancer and OAuth

I'm trying to set up a nginx loadbalancer/proxy for two servers, with OAuth authenticated apps running on both of them. Everything's running fine when nginx is running on port 80, but when I put it on any other port OAuth authentication fails with an "invalid signature" error message.

Here is my server config in nginx.conf:

server {
    listen 80;
    server_name localhost;
    location / {
      proxy_pass  http://webservice;

        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Port $server_port;
        proxy_set_header        X-Forwarded-Host $host;
        proxy_set_header        X-FORWARDED-PROTO https;
    }

Has anyone run into a similar problem?

PS: I've noticed that the port 80 is omitted from the OAuth realm property, but other ports are added normally.

Upvotes: 4

Views: 2515

Answers (1)

Tom van der Woerdt
Tom van der Woerdt

Reputation: 29975

That's probably not in any way related to nginx. OAuth (1, not 2) requires a signing URL, which would be http://webservice:81 if you moved it to port 81. Make sure that your OAuth code knows the website is actually on port 80 and not 81.

Either update your client to say it's port 81 or tell the server it's on 80.

Replace 81 with your favorite port

Upvotes: 6

Related Questions