If I want to route a HTTP request through a local (alias: on the current server) Proxy, how would I go around this?

The allowed Proxy settings for the wp-config.php are the following:

# HTTP Proxies
# Used for e.g. in Intranets
# Fixes Feeds as well
# Defines the proxy adresse.
define( 'WP_PROXY_HOST',          '' );
# Defines the proxy port.
define( 'WP_PROXY_PORT',          '8080' );
# Defines the proxy username.
define( 'WP_PROXY_USERNAME',      'my_user_name' );
# Defines the proxy password.
define( 'WP_PROXY_PASSWORD',      'my_password' );
# Allows you to define some adresses which 
# shouldn't be passed through a proxy.
define( 'WP_PROXY_BYPASS_HOSTS',  'localhost, www.example.com' );

This question is a follow up on this question.

  • I don't understand the question, exactly. You seem to have the answer right there. Those are the proxy settings for the HTTP API. If you have to go through a proxy to make external requests, then yep, that's how you do it.
    – Otto
    Dec 5, 2012 at 17:54
  • Read the initial question: Yes, these have nothing to do with reverse proxies. These are for making requests from WP to the outside world, through a proxy server.
    – Otto
    Dec 5, 2012 at 17:56
  • @Otto Yes, the answer is clear and yes it came out of the other question. Glad you got that point. WPSE is a reference system and lives from explanations and details not provided elsewhere or provided with more detail here... hence the question.
    – kaiser
    Dec 5, 2012 at 18:36
  • That doesn't make any sense. Why did you ask the question if you already knew the answer? Edit: You know what, nevermind, don't bother to explain. I'll just downvote and vote to delete it, because this makes no sense and shouldn't be here.
    – Otto
    Dec 5, 2012 at 23:16
  • 1
    @Otto As I stumbled upon your comment again: See this screenshot please.
    – kaiser
    Jan 19, 2013 at 10:39

1 Answer 1


The proxy settings work just like a regular HTTP requests but in this case obviously routed through a proxy. In terms of WordPress the API's transport layers all support proxy connections(fsockopen, fopen, cURL, ).

The things about proxy configurations are they come in several flavors and each setup is different so it makes answering this difficult, it doesn't really matter if your proxy is on your localhost or remote, the wp-config.php settings will work regardless. Typically you want to use these settings if your on an intranet/firewall that has specific requirements.

It is worth noting you can just set your localhost/webserver to use a proxy/chaining by default for HTTP requests and in that case it is not necessary to set any options with wp-config.php since this is configured at the server level . If you disable your proxy you typically see a response code of error 130 ERR_PROXY_CONNECTION_FAILED, but these setups are outside the scope of WordPress.

Some tools that can help you setup and debug proxy connections:

To dig into the WordPress HTTP API I recommend the following snippet using the http_api_debug action (altered to var_dump found via viper007bond's site):

add_action( 'http_api_debug', 'viper_http_api_debug', 10, 5 );

function viper_http_api_debug( $response, $type, $class, $args, $url ) {
    // You can change this from error_log() to var_dump() but it can break AJAX requests
    var_dump( 'Request URL: ' . var_export( $url, true ) );
    var_dump( 'Request Args: ' . var_export( $args, true ) );
    var_dump( 'Request Response : ' . var_export( $response, true ) );

The Request Response is the interesting part, sometimes you can tell with a quick glance if your request is going through proxy..

For example using the default HTTP API to make the following request.

$api_url = 'http://api.wordpress.org/secret-key/1.0/';
$response = wp_remote_get($api_url);
$header = wp_remote_retrieve_headers( $response );


enter image description here

Now the same exact request but using a remote proxy enabled via wp-config.php

//I grabbed these off of Google search they will not work for long.
define( 'WP_PROXY_HOST', '' );
define( 'WP_PROXY_PORT', '3128' );

enter image description here

As you can see the proxy the output is different, most importantly the proxy is adding the via tag, in this case a squid proxy. Proxies are supposed to do this and not alter the server response-header , but not everyone follows the rules so be careful;).

The constant define( 'WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com' ) is useful for allowing access to hosts that you might not want to go through a proxy (WordPress updates for example). The comments in the class-http.php are misleading because by default localhost and get_option('siteurl); are already included but can be altered via the pre_http_send_through_proxy filter.

Some additional options that work with the proxy settings are:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.