---
title: "corestack_nginx_rules_copy"
url: https://docs.corefinity.com/mcp/tools/corestack_nginx_rules_copy
type: tool
last_updated: 2026-11-13
feature: nginx-rules
related:
  - https://docs.corefinity.com/api/reference/site-settings/copy-site-nginx-rules.md
  - https://docs.corefinity.com/guides/sites/site-settings/web-server-rules.md
---
# corestack_nginx_rules_copy

**Copy nginx rules from another environment.** Copy the live nginx rules of another environment of the same site onto this environment row (promote staging to production on the production row, with confirm_production). The web root in the rules is rewritten for the target. dry_run previews the result without saving; otherwise the copy is checked, tested and saved like any change and needs the target's version from corestack_nginx_rules_get. Scope: write. Long-running: answers with a task.

- Scope: `write`
- Confirmation: `confirm_production`
- Runs as a task: yes

## When to use it

Copy the live nginx rules of another environment of the same site onto this environment row (promote staging to production on the production row, with confirm_production). The web root in the rules is rewritten for the target. dry_run previews the result without saving; otherwise the copy is checked, tested and saved like any change and needs the target's version from corestack_nginx_rules_get.

A dry run answers `{state: dry_run, content, rewrites, diff, diagnostics, source_revision}`: the copied hooks, each web-root rewrite (`hook`, `from`, `to`, `count`), a unified diff per hook (null where it does not change) and the diagnostics the save would give. A copy answers as corestack_nginx_rules_update. The pins of the token must cover both environments.

## Inputs

- `site_id` (integer, ≥ 1, required): The target environment row.
- `from_site_id` (integer, ≥ 1, required): Another environment of the same site to copy from.
- `version` (integer, ≥ 0): The target's version from corestack_nginx_rules_get (not needed for a dry run).
- `hooks` (list of `server`, `headers`, `php`, `http`): The hooks to copy (default all).
- `note` (string, at most 200 characters): Why, shown in the history (default "Copied from {source}").
- `dry_run` (boolean): Preview the copy: the content, the rewrites, a diff per hook and diagnostics; nothing is saved.
- `confirm_production` (boolean): Required (true) when the target is the production environment.
- `apply` (string, `now` or `tonight`): Only when the copy adopts the runtime update on save: now or tonight. Default now.

### Input schema

```json
{
  "additionalProperties": false,
  "properties": {
    "apply": {
      "default": "now",
      "description": "Only when the copy adopts the runtime update on save: now or tonight. Default now. window: the row's next maintenance window (tonight is kept as its alias).",
      "enum": [
        "now",
        "window",
        "tonight"
      ],
      "type": "string"
    },
    "confirm_production": {
      "description": "Required (true) when the target is the production environment.",
      "type": "boolean"
    },
    "dry_run": {
      "description": "Preview the copy: the content, the rewrites, a diff per hook and diagnostics; nothing is saved.",
      "type": "boolean"
    },
    "from_site_id": {
      "description": "Another environment of the same site to copy from.",
      "minimum": 1,
      "type": "integer"
    },
    "hooks": {
      "description": "The parts to copy (default all).",
      "items": {
        "enum": [
          "server",
          "headers",
          "php",
          "http",
          "path_apps"
        ],
        "type": "string"
      },
      "maxItems": 5,
      "minItems": 1,
      "type": "array"
    },
    "note": {
      "description": "Why, shown in the history (default \"Copied from {source}\").",
      "maxLength": 200,
      "type": "string"
    },
    "site_id": {
      "description": "The target environment row.",
      "minimum": 1,
      "type": "integer"
    },
    "version": {
      "description": "The target's version from corestack_nginx_rules_get (not needed for a dry run).",
      "minimum": 0,
      "type": "integer"
    }
  },
  "required": [
    "site_id",
    "from_site_id"
  ],
  "type": "object"
}
```

## Refusals

- `confirm`: the target is production and `confirm_production` was not true.
- `stale`: the rules changed since `version` was read; read them again with corestack_nginx_rules_get.
- `nginx_invalid`: the policy refused the rules; `details.diagnostics` lists each error with hook, file line and column. When the rules need the environment's runtime update and the platform has no model for the revision it would move to, every hook answers `runtime_model_missing` naming that revision 'after this change': support moves the site to a supported revision.
- `nginx_test_failed`: nginx -t failed on the environment's nginx; `details.diagnostics`.
- `hook_unavailable`: a hook (or a rule) needs the one-time runtime update, which cannot be turned on for this environment yet.
- `nginx_rules_locked`: Corefinity staff hold this environment's nginx rules.
- `busy`: another change runs on the environment; retry when it ends.
- `change_pending`: a change is queued for tonight.
- `batch_window`: adopting now is not possible outside the environment's window; send `apply: tonight`.
- `migration_halted`: the night's migration is halted; send `apply: tonight`.
- `apm_provenance_unreadable`, `image_volume_unsupported`, `legacy_module_unmapped`: the runtime update cannot be turned on until Corefinity checks the environment (contact support).
- `too_large`: a hook is over its size limit.
- `managed_elsewhere` (message: "This site is managed by another control panel"): another control panel manages this site, so use that control panel for it. This is refused before anything else about the site, as in the Control Panel and the API. Nothing was done.
- The refusals every tool can answer: `invalid_arguments`, `tenant_mismatch`, `scope_required`, `pin_refused`, `rate_limited`, `temporarily_unavailable`, `internal_error` (corestack://guides/how-this-server-works).

## Example

```json
{
  "name": "corestack_nginx_rules_copy",
  "arguments": {
    "site_id": 4212,
    "from_site_id": 4211,
    "dry_run": true
  }
}
```

## Path apps

A copy also carries the source's path apps and gates: `hooks` may name `path_apps` beside the four hooks, and leaving `hooks` out copies all five. The source's list replaces the target's whole list. A record limited to hosts keeps the ones the target also has; one left with none is not copied (it never widens to all hosts), and the copy names it: `warnings` in the dry run, `path_app_not_carried` with the record, its prefix and the hosts dropped. The dry run's `content.path_apps` is the list the target would get and `diff.path_apps` its unified diff against the target's, written as YAML. A target whose runtime cannot serve path apps yet refuses `path_apps_unavailable`.

## Prompt

```text
Using the Corefinity MCP server, call corestack_nginx_rules_copy with site_id 4212, from_site_id 4211, dry_run true. (Copy nginx rules from another environment.) Tell me what it returned.
```

## The same task elsewhere

- Endpoint: [POST /api/corestack/sites/{site}/nginx-rules/copy](https://docs.corefinity.com/api/reference/site-settings/copy-site-nginx-rules.md)
- Guide: [Web server rules](https://docs.corefinity.com/guides/sites/site-settings/web-server-rules.md)
