Connect to Jetpack using behind varnish and nginx

Normally if you use varnish or other reverse proxy, you may use other port in wordpress. So you are not able to connect to Jetpack, because to connect Jetpack, you must have port 80 to authorize.

It may display the error like this from your Jetpack debugger

SELF:
	Array
(
    [headers] => Array
        (
            [server] => nginx
            [date] => Sat, 23 Aug 2014 00:57:12 GMT
            [content-type] => text/plain;charset=utf-8
            [connection] => close
            [x-pingback] => https://jetpack.wordpress.com/xmlrpc.php
            [expires] => Wed, 11 Jan 1984 05:00:00 GMT
            [cache-control] => no-cache, must-revalidate, max-age=60
            [pragma] => no-cache
            [x-hacker] => Jetpack Test
        )

    [body] => {"error":"Communication error","error_description":"We were unable to make an XML-RPC request to your website. Please make sure that XML-RPC is turned on and that Jetpack is installed, activated and connected with your WordPress.com account. If the error persists, try disconnecting and connecting Jetpack again."}
    [response] => Array
        (
            [code] => 400
            [message] => Bad Request
        )

    [cookies] => Array
        (
        )

    [filename] => 
)

because of the $_SERVER[‘SERVER_PORT’] is not equal to value 80;
But we can cheat the Jetpack by add this to wp-config.php

$_SERVER['SERVER_PORT'] = 80;

Tags:

4 thoughts on “Connect to Jetpack using behind varnish and nginx”

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.