RAMP Communication Endpoints
Default behavior
RAMP must be able to make HTTP requests from the staging server to the production server and from the production server to the staging server. Generally, this requires port 80 to be accessible in both directions (and may require port 443, depending on SSL configurations), and for those HTTP requests not to require a username and password (401 authentication) to succeed.
Staging to Production (Sending Content)
The staging server makes XML-RPC calls to the production server to send new and updated content, and must be able to communicate to the XML-RPC endpoint. The staging server builds the XML-RPC endpoint by appending xmlrpc.php
to the Remote Server Address specified in the RAMP settings, and makes standard HTTP requests (port 80, or 443 for https, by default) to this endpoint. For example: http://example.com/path/to/wordpress/xmlrpc.php
If you need to change the port RAMP uses for XML-RPC, WordPress must also be configured to recognize the alternate port. This is only possible in a non-multisite install. Since the WordPress Address in the General settings page only allows a single address, this must be done in wp-config.php
.
Caution: setting or changing WP_SITEURL
can be a security risk and may break functionality.
To let WordPress accept both port 80 and port 8080, assuming WP_SITEURL
is not already defined, add a line to the wp-config.php
before the That's all, stop editing!
line:
define('WP_SITEURL', 'http://example.com' . ('8080' === $_SERVER['SERVER_PORT'] ? ':8080' : '') . '/path/to/wordpress');
The web server and any firewalls must also be configured to respond to an alternate port.
To cause RAMP to communicate with the XML-RPC endpoint using the alternate port, specify the port in the Remote Server Address. For the above example: http://example.com:8080/path/to/wordpress/
Production to Staging (Importing Attachments)
The production server makes standard HTTP GET requests to the staging server (using wp_get_http
) to fetch attachment files. The URL for these files is built with wp_get_attachment_url
and filtered with cf_deploy_absolute_url
.
If a different URL to the staging server is requred, add a filter to cf_deploy_absolute_url
. For example, to add port 8080:
function change_ramp_attachment_url($url) {
$parsed = parse_url($url);
if (!isset($parsed['port'])) {
$host_part = '://' . $parsed['host'];
$new_url = str_replace($host_part . '/', $host_part . ':8080/', $url);
return $new_url;
}
return $url;
}
add_filter('cf_deploy_absolute_url', 'change_ramp_attachment_url', 20);
The priority of 20 is only important if Root Relative URLs or another similar plugin is installed; RAMP has a default filter at priority 10 to ensure that the attachment URLs are converted to absolute URLs in this case.