简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM