CorefinityCorefinityDocs
Open the Control PanelControl Panel
Web server rules · 3 of 19

Replace a site's Nginx rules

Saves the hooks sent in content at the version you read: a hook left out stays as it is, and "" or null clears it. The change is checked, tested, applied and verified against the site's health check and verify paths, and one that fails is put back automatically: follow the operation in the answer. verify_paths may be sent without content.

PUT/api/corestack/sites/{site}/nginx-rules

Path parameters

siteintegerRequired

The id of a site row. A website's production site and each of its environments has its own id. Digits only. At least 1.

Body

applystring

When the change applies, if it needs a one-time update of the site's runtime first. Most changes apply at once whatever is sent. When a change that needs a maintenance window is applied. now applies it at once. tonight queues it for the site's next window. window means the same as tonight. An endpoint that takes window only while maintenance windows are on for your company says so, and refuses it 422 on apply otherwise. Defaults to now.

nowtonightwindow
Fields
contentobject

The text of each hook sent. server goes inside the site's server block (locations, return, rewrite), headers sets response headers for every page, php holds settings for PHP requests and http sits at the http level, for example a map.

Fields
headersstring or null
httpstring or null
phpstring or null
serverstring or null
notestring or null

Why, shown in the history. Up to 200 characters.

path_appsarray of objects or null

The whole list of path apps and gates: [] removes every one, and leaving it out or sending null keeps the saved list. It may be sent without content. A list whose labels alone changed answers a revision with operation: null. Refused invalid while path apps are not on for your company.

Fields of each item
hostsarray of strings

Some of the site's hostnames. Empty means all of them. Up to 16 items.

idstring

a1, a2 and so on for a PHP app, static folder, other site or closed path; g1, g2 and so on for a gate. Keep it when you change a record. A new record may leave it out: it is given the next free number.

ipsarray of strings

Addresses or networks admitted, up to 64. A gate needs at least one. A network of /8 or wider, an address in a special-purpose range (the documentation ranges among them) and the platform's own ranges are refused.

labelstring

A note. Empty when left out. Null is refused. Defaults to ``. Up to 80 characters.

limitsobject

For a PHP app.

Fields
body_size_mbinteger or null

The largest request body in MB, at most the site's upload size. Null, the default, leaves the site's own limit in force. Defaults to null. At least 1.

timeoutinteger

The PHP time limit in seconds. Defaults to 300. 30 to 300.

linksarray of objects

For a PHP app or static folder on a folder path: up to 4 folders of the path app that are served from the site's shared folder, such as its uploads. Left out of a saved record when there are none.

Fields of each item
pathstringRequired

A folder of the path app, relative to its path and ending in /, such as wp-content/uploads/. Two links cannot share a folder or lie inside one another, and PHP never runs under a link.

targetstringRequired

A folder below the site's shared folder that holds only public files, such as shared/wp-content/uploads on WordPress, with no trailing /. Refused: shared itself, a hidden folder (a name that starts with .), and a folder that is, is inside or contains one where the platform keeps code, logs or secrets, such as shared/logs or shared/vendor. The list differs per platform; on WordPress shared/wp-content/uploads and the folders below it are allowed although the rest of shared/wp-content is not.

methodsarray of strings

The request methods admitted. GET, HEAD and POST when left out.

GETHEADPOSTPUTPATCHDELETEOPTIONS
phpobject

For a PHP app, which needs it.

Fields
dir_indexarray of strings

Up to 8 folders whose index.php answers the folder, such as wp-admin/.

entriesarray of stringsRequired

1 to 32 PHP files that may run, relative to the path, such as wp-login.php or wp-admin/*.php. Every other PHP file under the path answers 404.

routerarray of strings

Up to 4 folders passed to the app's index.php, such as wp-json/, or / for the whole app.

prefixstringRequired

The path, such as /wp/. A PHP app or a gate can also name one file, and a gate / with hosts.

presetstring or null

The preset the record started from.

proxyobject

For another site on the path, which needs it.

Fields
connect_timeoutinteger

Defaults to 5. 1 to 30.

host_headerstring

target (the other site's own name), visitor (the name the visitor used) or another host name. Defaults to target.

pathstring

keep sends the path as it is; strip leaves your path out. Defaults to keep.

keepstrip
read_timeoutinteger

Defaults to 60. 5 to 300.

share_cookiesboolean

True sends your visitors' cookies and logins to the other site and lets it set cookies here. Defaults to false.

urlstringRequired

The other site: https://, a host name and optionally a port and a folder. Up to 255 characters.

rateobject or null

A rate limit per visitor, for a PHP app, a static folder or another site. Send both fields, or leave rate out (or send null) for no limit. Left out of a saved record that has none.

Fields
burstintegerRequired

0 to 1000.

per_secondintegerRequired

1 to 1000.

rootstring

For a PHP app or static folder: htdocs or shared, optionally with sub-folders.

staticobject

For a PHP app or static folder.

Fields
typesarray of strings

Lower-case file extensions served from disk, up to 32. The policy's default list when left out. A static folder serves at least one.

typestringRequired

A PHP app, a static folder, another site shown on the path (proxy), a closed path (deny) or a gate that admits only listed addresses.

php-appstaticproxydenygate
test_idinteger

A passed test run of the same content, from a check, so it is not run again. At least 1.

verify_pathsarray of objects

Replaces the list of paths checked after every change. Sent on its own, only this list is saved. Up to 5 items.

Fields of each item
expectstring

The answer expected: an exact status such as 403, a class such as 2xx, or <500. Defaults to <500.

pathstringRequired

A path on the site, starting with /.

versionintegerRequired

The version from the last read. At least 0.

Returns

200 Nothing was started: the content is what the site already has (operation and revision are null), or only the verify paths were saved (version and verify_paths).

201 The change was saved. Follow operation; revision is the new revision. A change that waits for a window answers queued: true with nothing started.

Fields of the 200 answer
Fields of the 201 answer
item_idinteger or null

The id of the queued change.

operationobject or any or nullRequired

The change to follow. Null when nothing was started.

path_app_warningsarray of objects

On a copy that carried path apps: the records that were not carried (path_app_not_carried).

queuedboolean

Present when the change waits for a window.

revisionobject or any or nullRequired

The new revision. Null when there is none.

windowobject or any or null

The window a queued change waits for. Present only while maintenance windows are on for your company.

window_datestring or null

The date of the window a queued change waits for.

If it is refused

StatusReasonWhat to do
401noneSend a valid token as Authorization: Bearer <token>.
403company_unavailableYour company is unavailable.
403scope_requiredUse a token with the scope named in scope.
403two_factor_requiredTurn on two-factor on your account, then send again.
404feature_offThis feature is not on for your organisation yet.
409busyAnother operation is running on the site. Wait for it to finish.
409conflictThe action conflicts with the object's present state. Read the message.
409managed_elsewhereThis site is read-only here. Change it in the control panel that manages it.
409restore_runningA restore is running on the site. Wait for it to finish, then try again.
409staleWhat you read has changed since you read it. Read it again, then send the change with its new version or quote.
413too_largeThe upload is larger than the limit for one file.
422feature_offThis feature is not on for your organisation yet.
422invalidFix the field named in field; errors says why.
422nginx_invalidThese nginx rules cannot be saved: fix the errors shown.
422nginx_rules_lockedCorefinity has locked this environment's nginx rules. Contact support to change them.
429rate_limitedWait for the seconds in Retry-After.
500noneRead the message; it says what happened.
502noneRead the message; it says what happened.
503upstream_unavailableA service the action depends on did not answer. Try again later.

Reasons are listed by name in Errors and refusals.

The same task elsewhere

curl -X PUT https://manage.corefinity.com/api/corestack/sites/1042/nginx-rules \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "WordPress admin under /wp/",
    "path_apps": [
      {
        "label": "Blog admin",
        "php": {
          "dir_index": [
            "wp-admin/"
          ],
          "entries": [
            "wp-admin/*.php",
            "wp-login.php"
          ],
          "router": [
            "wp-json/"
          ]
        },
        "prefix": "/wp/",
        "preset": "wordpress-admin",
        "root": "htdocs",
        "type": "php-app"
      }
    ],
    "version": 0
  }'
{
  "operation": null,
  "revision": null
}
Try it

Try it is off for this endpointIt overwrites data that cannot be brought back. Copy the request and run it yourself when you are sure.

Was this helpful?
Open in ClaudeOpen in ChatGPT