0

Forgive me if this is an easy question, all... I've spent an hour Googling this and can't come up with an answer that makes sense.

MY SETUP: Wordpress running on nginx with varnish Varnish listening on 80 Nginx listening on 8080

MY ISSUE: On my WP site, if someone clicks the "Log In With Facebook" button from "mysite.com/somepage", after a long wait, the browser bar shows "mysite.com:8080/somepage/ and I'm getting that fun "Oops! Google Chrome could not connect" error.

From what I've read, I get the sense that the issue is with my nginx.conf, but I haven't the slightest idea how to fix it; and it's on a live site, so monkeying around nailing Jell-O to the wall isn't something I'm comfy with. And I'm not even 100% certain what you're going to ask me to show you from my config files, but here's what I can think of so far...

This config was done by a third party, but here's some basic info that might help...

Start of my /etc/nginx/sites-enabled/wordpress

server {
    listen       8080;
    server_name  mysite.com;
    root         /var/www/wordpress;

    index index.php;

Portion of /etc/default/varnish

DAEMON_OPTS="-a XXX.XXX.XXX.XXX:80 \                                                                   
         -T localhost:6082 \                                                                      
         -f /etc/varnish/wordpress.vcl \ 
         -S /etc/varnish/secret \ 
         -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"

Also this from /etc/varnish/default.vcl:

backend default {                                                                                     
    .host = "127.0.0.1";                                                                              
    .port = "8080";                                                                                   
} 

I'm afraid to edit this and break the whole site. Anything jump out?

UPDATE: In case this is of any use, I found the URL my browser is TRYING to get to after I click the Facebook login button (this results in being taken back to the page I logged in from, with ':8080' being appended to the end of 'mysite.com'):

mysite.com/?code=AQBsvAQ3jFCJtYQO8AEhz-V8Yqr4HnhpZLaaqFjnvQenwp9FnvIBYGLdus2_vltS0LKicF2QiVKPewrfpRB2ODKF04PkHgJK-KynG3m0xxtztrdXUKPNgPVJ7YxQjnf1kcPagCm5dRjyAqeRw7Xr7exfrLP40yFLSR_eyrJvWUT9oF7ibpX_3883VWunJ3PX5keI7FYCvz2iWvdchWCGOFyBNAI_xtGLwPuMghij1xGRhp2P7dlGnm6GqVqeKO6oe3lhPDBuD0ogGV3TgbWfmC8omMf1d70YHhws3xtx7Lr2lvYPRsKAY5YU9v8x4qRAfvw#_=_

...wondering now if the "code=" in the URL is somehow being grabbed by the rewrite rules?

ANOTHER UPDATE Having found this URL about a plugin that's functionally similar to a Facebook login plugin I'm trying to use, I followed the suggestion and made the following edit, which at least stopped the errant redirect. Now I have a different problem for a different forum (namely that the plugin doesn't actually log the user in).

EDITED

$request_port = ((!empty ($_SERVER ['SERVER_PORT']) AND $_SERVER ['SERVER_PORT'] <> '80') ? (":" . $_SERVER ['SERVER_PORT']) : '');

to

$request_port = '';
Neil
  • 95
  • 1
  • 1
  • 8
  • Following scattered advice around the interwebs, have tried adding `port_in_redirect off;` to the server block, still having the error. – Neil Nov 20 '13 at 21:40

3 Answers3

0

It turns out the issue is only partially related to my nginx/varnish setup.

The actual culprit is the #= that Facebook adds to their redirect uri.

Details here.

Community
  • 1
  • 1
Neil
  • 95
  • 1
  • 1
  • 8
0

The two only ways for Facebook to know where it should go after log in are

  • The URL you provide to the Facebook application settings ( the one you use as app_id ).
  • And the URL you pass to the log in function call as a return URL

And I think the second one is your problem, when you create the facebook login link, you pass it a URL telling it where it should return to when it's finished, if the return URL is generated from your app then it's probably you'll find that function adding the 8080 too.

Check that function and make sure that it doesn't contain the 8080

Mohammad AbuShady
  • 40,884
  • 11
  • 78
  • 89
0

Try adding

port_in_redirect off;

under your server block

http://zach-adams.com/2014/05/fix-wordpress-8080-port-redirects/

EbilGenius
  • 69
  • 1
  • 9