• Resolved austincollinpena

    (@austincollinpena)


    I did my homework before coming here!

    Here’s my problem, I have a reverse proxy that’s forwarding all of my Post requests, and something seems to be ignored and the correct pricing doesn’t show.

    In my reverse proxy, I set the HTTP_X_FORWARED_FOR (and [HTTP_X_REAL_IP]) to “93.187.216.173”. I have verified that it gets set to that IP by printing it out (see attached page).

    Looking up this URL in the maxmind database, I can see that I get Canada, but when I make the request, it thinks I’m from the US.

    In database_required you check for additional headers, but when printing out the headers, I don’t see any of those headers that could interfere.

    Lastly, I know this works because it works just fine on the apex domain. It’s just the reverse proxy that’s doing something. So I’m sure I’m missing something small.

    Ps. This is all done on the www subdomain. If you click to another page you’ll be at the apex domain. Here’s where it should show up in Canada https://www.delozio.com/produit/meglio?cache=bust123

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Oscar Gare

    (@oscargare)

    Hi,
    the real IP are in the HTTP_FLY_CLIENT_IP $_SERVER var.

    Since the WooCommerce geolocation function gets the real IP from the first var not empty of HTTP_X_REAL_IP, HTTP_X_FORWARDED_FOR, REMOTE_ADDR, you will have to overwrite the HTTP_X_REAL_IP var for the geolocation function uses the value of HTTP_FLY_CLIENT_IP:
    https://github.com/woocommerce/woocommerce/blob/master/includes/class-wc-geolocation.php#L75

    Adding to your config.php the following code before /* That's all, stop editing! Happy blogging. */ should solve the geolocation issue:

    $_SERVER['HTTP_X_REAL_IP'] = $_SERVER['HTTP_FLY_CLIENT_IP'];

    • This reply was modified 4 years, 5 months ago by Oscar Gare.
    Thread Starter austincollinpena

    (@austincollinpena)

    Thanks for such a timely response Oscar! I think I didn’t communicate well enough to you. Forgive the non-PHP code but it should self-explanatory:

    go
    	flyHeader := req.Header.Get("Fly-Client-IP")
    	if flyHeader != "" {
    		flyHeader = "96.127.201.166"
    		req.Header.Set("X-FORWARDED-FOR", flyHeader)
    		req.Header.Set("X-REAL-IP", flyHeader)
    		req.Header.Set("test-header", "itsgooditgetsset")
    	}
    	req.RemoteAddr = flyHeader
    	logger.Logger.Info().Msgf("Set the forward header to %s\n\n", req.Header.Get("x-real-ip"))
    

    What I’m doing is purposefully setting the header to a Canadian IP so I in America can see if it works, but for some reason it’s still not getting parsed. I figured I was setting a header wrong or something else.

    With that in mind, do you have any ideas for what could be going on?

    Plugin Author Oscar Gare

    (@oscargare)

    Hi,
    make sure you are excluding the URL that contains the query string wc-ajax from the cache.

    Other tips:

    * Add $_SERVER[‘HTTP_X_REAL_IP’] = $_SERVER[‘HTTP_FLY_CLIENT_IP’] to the config.php, and do the test with a VPN instead of by changing the headers (review How to test Price Based on Country)
    * USD and CAD have the same symbol, check that the price changes.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Load products in the background doesn’t work’ is closed to new replies.