Domain Mapping Redirect when Logged In

Trying to visit one of my subblogs that is using domain mapping.

When I visit the domain and am logged in as a network admin it is re-directing multiple times and not showing the site.

If I am logged out and visit the site it is showing the mapped domain site without issue.

I am on a mac using safari all latest versions. It is also happening in chrome.

I notice it seems to be toggling between the mapped domain i.e.:

http://www.domain.com/

and

http://www.domain.com/?__domainmap_action=domainmap-authorize-user&auth=ben|1407654681|1234567802bed07545e1b38787581208

(numbers after ben were changed for example)

Ideas?

  • Vinod Dalvi

    Hi @Ben,

    Sorry to hear of the problem you are having.

    Please make sure you have configured the Domain Mapping plugin correctly as described on the following page.

    https://premium.wpmudev.org/project/domain-mapping/#usage

    Please share me if you can your original and mapped domains URLs so that i can test it.

    Also share me the screenshots of your Domain Mapping settings or Would you mind if I logged in to your site and did some testing? This might help get to the bottom of this faster. If this is ok, just grant me temporary admin access to your site by clicking "Grant Access" button in the WPMU DEV Dashboard Settings from the following path and reply on this thread after granting it?

    Admin -> WPMU DEV -> Support -> Support Access Tab

    Kind Regards,
    Vinod Dalvi

  • Ben

    @Vinod Dalvi

    Okay...so I turned off my caching varnish and the redirect seems to have gone away. So varnish used to work with domain mapping, however it seems to no longer work and is giving a re-direct when visiting the mapped domain ONLY when authenticated.

    I think somewhere the issue is related to the code relating to this line of code being injected:

    <script type="text/javascript" src="https://MYMAINDOMAIN.com/wp-admin/admin-ajax.php?action=domainmap-setup-cdsso"></script>

    Which upon further inspection is giving the following javascript to create the redirect:

    window.location = "http://www.MAPPEDDOMAIN.com/?__domainmap_action=domainmap-authorize-user&auth=USERNAME|140000003|9d9000d10000ddssa918263e75bb703";

    Could you tap the shoulder of the domain mapping plugin dev to perhaps gain some insite on this issue? Wondering if a new cookie was introduced that I might need to tell varnish to ignore or something along those lines...Thanks!

  • Ben

    @Vinod Dalvi

    I think I solved this problem with some adjustments to my varnish code, here are the following items i have in my default.vcl file vcl_recv area:

    sub vcl_recv {
      if (req.url ~ "\?__domainmap_action") {
        return(pipe);
      }
    
      if (req.http.Cookie ~ "auth" || req.http.Cookie ~ "noaffiliate_" ||  req.http.Cookie ~ "__utma" || req.http.Cookie ~ "wordpress_" || req.http.Cookie ~ "mp_session" || req.http.Cookie == "PHPSESSID" || req.http.Cookie ~ "mp_globalcart_" || req.http.Cookie ~ "wordpress_test_cookie") {
        remove req.http.Cookie;
      }
    
      if (req.request == "POST" || req.request == "PUT") {
        return(pass);
      }
    }

    Hope that helps...it seems to be correcting the problem for me, if anybody else has some incite please post! Thanks!

    Varnish is very powerful and helpful at speeding sites up, perhaps it would be cool to have a page on wpmudev to give best varnish practices.