WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 21 months ago

Last modified 21 months ago

#17096 closed defect (bug) (invalid)

WP_HTTP_Proxy :: Host check prevents proxying to local

Reported by: jimmynguyc Owned by:
Priority: normal Milestone:
Component: HTTP Version: 3.1
Severity: normal Keywords: has-patch 2nd-opinion
Cc:

Description

Blog URL check should be optional by defining them in WP_PROXY_BYPASS_HOSTS.

Forcing this check denies me from proxying my blog URL through 127.0.0.1, which is needed because I'm ProxyPass-ing certain /directories to another server.

E.g.

<VirtualHost *:80>

ServerName mysite.com
ProxyPass /special http://www.mysite.com/special

</VirtualHost>

/special is on a separate server running another CMS. Its IP is hardcoded in the server's hosts file.

Hence,

I will have this in my wp-config.php for the WP http requests to work.

define('WP_PROXY_HOST', '127.0.0.1');
define('WP_PROXY_PORT', '80');
define('WP_PROXY_BYPASS_HOSTS','');

Attachments (1)

17096.diff (412 bytes) - added by jimmynguyc 2 years ago.

Download all attachments as: .zip

Change History (6)

jimmynguyc2 years ago

comment:1 dd3221 months ago

  • Keywords 2nd-opinion added

The check here would be to prevent Cron loopback requests from being made via the proxy.. I don't think we can change/remove that.

comment:2 jimmynguyc21 months ago

Well in my case I needed the cron to loopback because resolving the hostname will point the request to another server, as the host file was hardcoded to a different server for the domain name.

As mentioned I needed to do a proxypass of a certain subfolder to a different server, hence the hardcoded IP in /etc/hosts.

It works fine as long as the request came from outside, but if a request came from the server (e.g. a cron task) it will be pointing to a different IP as per defined in /etc/hosts. Meaning that crons jobs will never be executed.

Hence the hack and the WP_HTTP_PROXY workaround which I found is the only way to fix my problem.

Any thoughts?

comment:3 dd3221 months ago

Ultimately, If the IP address of current site is redirected elsewhere, it's not going to end well..

The "common" way to do that would be have the other server named differently eg:

ServerName mysite.com
ProxyPass /special http://www2.mysite.com/special

that way DNS hacking isn't needed.

The Proxy support in core is designed for outgoing requests, rather than loopback requests.

In your case, I'd be filtering outgoing HTTP requests, If it's for the current domain, alter the request to goto http://127.0.0.1/ and force a Host header.. WordPress Beta Tester plugin intercepts connections and rewrites them, you might be able to do something similar.

comment:4 jimmynguyc21 months ago

  • Resolution set to invalid
  • Status changed from new to closed

Thanks I'll give that a try :)

comment:5 SergeyBiryukov21 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.