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
        (
             => 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;

Author: Justin Soo

https://plus.google.com/105604283199591348183