Rule Engine

Map Remote

Redirect matched requests to a different host without changing your code or modifying the system hosts file. Switch targets instantly.

Map Remote lets you redirect traffic from one host to another entirely within HTTPeep. When a request matches a rule configured with Map Remote, HTTPeep rewrites the destination and forwards the request to the target host you specify. Your application's code, the URL in the browser, and any logs all continue to show the original URL — only the actual TCP connection goes to a different server.

How it works

HTTPeep intercepts the matched request, replaces the host (and optionally the scheme and port) with your configured target, forwards the request, and returns the response to your application as normal. From the perspective of your code, nothing has changed. From the perspective of your network, the request went to a completely different machine.

This differs from editing /etc/hosts in two important ways: it applies only to traffic that flows through HTTPeep, and you can switch or disable it instantly without any system-level changes.

Use cases

Point production traffic at your local service

Redirect api.example.com to localhost:3000 to test your local backend against production frontend code, without deploying anything.

Switch between environments

Redirect your app's production API calls to a staging or QA environment. Toggle the rule on and off without touching your configuration files.

Route around a broken service

Temporarily redirect traffic away from a service that is down to a fallback or mirror, without a code deploy.

Canary and A/B testing

Route a specific subset of traffic (matched by path or header) to a different backend to compare behavior between versions.

Configuring Map Remote

In the Rules panel, click New Rule or open an existing rule.

Configure the domain and any path, header, or query conditions to select the traffic you want to redirect.

In the Resolve section, select Map Remote.

Specify the target host, port, and protocol. For example: http://localhost:3000 or https://staging.api.example.com.

Save the rule. The next matching request is forwarded to the new target.

- id: rule_map_remote_01
  description: "Redirect production API to local service"
  enabled: true
  builtin: false
  stopAfterMatched: true
  match:
    domains:
      - type: exact
        value: api.example.com
    originProtocol: https
  requestActions: []
  resolve:
    type: map_remote
    target: http://localhost:3000
  responseActions: []

To redirect to a staging environment:

resolve:
  type: map_remote
  target: https://staging.api.example.com

Switching targets quickly

Because rules are stored as YAML files, switching between targets is as simple as editing the target field and saving. You can also:

  • Toggle the rule on and off using the enable/disable toggle in the Rules panel, without removing the configuration
  • Duplicate the rule with different targets and enable only the one you need at a given time
  • Use stopAfterMatched: true so only the first matching rule applies, allowing you to stack environment-specific rules and control priority

Keep one rule per environment (dev, staging, prod) and toggle between them as needed. This is faster and less error-prone than editing the target value each time.

Combining with request actions

Map Remote works well alongside request actions. For example, you can add an Authorization header before forwarding to a staging server that requires authentication, or strip a header that would cause issues with the target:

requestActions:
  - type: rewrite_header
    id: action_add_auth
    enabled: true
    header: Authorization
    value: "Bearer staging-token-abc123"
resolve:
  type: map_remote
  target: https://staging.api.example.com

Map Remote does not change the URL that your application or browser sees. If the target server returns a redirect (3xx), your client follows the redirect to the new URL as normal, which may take it outside HTTPeep's proxied traffic.

本页目录