Check Nginx rules without saving
Checks the hooks sent in content against the policy; a hook left out is the saved one. When there are no errors the rules are also tested with the site's own Nginx, unless sandbox is false: test names the run, and reading it answers its result. Nothing is saved.
Path parameters
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
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
A list of path apps to check instead of the saved one; it may be sent without content. Only while path apps are on for your company.
Fields of each item
Some of the site's hostnames. Empty means all of them. Up to 16 items.
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.
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.
A note. Empty when left out. Null is refused. Defaults to ``. Up to 80 characters.
For a PHP app.
Fields
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.
The PHP time limit in seconds. Defaults to 300. 30 to 300.
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
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.
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.
The request methods admitted. GET, HEAD and POST when left out.
GETHEADPOSTPUTPATCHDELETEOPTIONSFor a PHP app, which needs it.
Fields
Up to 8 folders whose index.php answers the folder, such as wp-admin/.
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.
Up to 4 folders passed to the app's index.php, such as wp-json/, or / for the whole app.
The path, such as /wp/. A PHP app or a gate can also name one file, and a gate / with hosts.
The preset the record started from.
For another site on the path, which needs it.
Fields
Defaults to 5. 1 to 30.
target (the other site's own name), visitor (the name the visitor used) or another host name. Defaults to target.
keep sends the path as it is; strip leaves your path out. Defaults to keep.
keepstripDefaults to 60. 5 to 300.
True sends your visitors' cookies and logins to the other site and lets it set cookies here. Defaults to false.
The other site: https://, a host name and optionally a port and a folder. Up to 255 characters.
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
0 to 1000.
1 to 1000.
For a PHP app or static folder: htdocs or shared, optionally with sub-folders.
For a PHP app or static folder.
Fields
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.
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-appstaticproxydenygateTrue adds path_apps_rendered to the answer. Only while path apps are on for your company. Defaults to false.
False checks against the policy only and skips the test on the site's own Nginx. Defaults to true.
Returns
200 What the check found. An empty diagnostics means the rules pass.
Fields of the 200 answer
Fields of each item
A stable code for the problem, such as root_outside_webroot.
For a path app, the field, such as php.entries.1.
The part of the rules it is in, such as server.
For a path app, the id of the record. hook is then path_apps.
error refuses a save; anything else is a warning.
What found it, such as policy.
With render: true: the Nginx text written for the path apps. Null when there are none or they have errors.
The test run that was started. Null when the test was skipped or the policy found errors.
If it is refused
| Status | Reason | What to do |
|---|---|---|
401 | none | Send a valid token as Authorization: Bearer <token>. |
403 | company_unavailable | Your company is unavailable. |
403 | scope_required | Use a token with the scope named in scope. |
403 | two_factor_required | Turn on two-factor on your account, then send again. |
404 | feature_off | This feature is not on for your organisation yet. |
409 | managed_elsewhere | This site is read-only here. Change it in the control panel that manages it. |
413 | too_large | The upload is larger than the limit for one file. |
422 | invalid | Fix the field named in field; errors says why. |
429 | rate_limited | Wait for the seconds in Retry-After. |
500 | none | Read the message; it says what happened. |
Reasons are listed by name in Errors and refusals.
The same task elsewhere
curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/nginx-rules/validate \
-H "Authorization: Bearer $COREFINITY_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"content": {
"server": "location = /private-report.pdf {\n return 404;\n}\n"
}
}'use Illuminate\Support\Facades\Http;
$response = Http::withToken(env('COREFINITY_TOKEN'))
->acceptJson()
->post('https://manage.corefinity.com/api/corestack/sites/1042/nginx-rules/validate', [
'content' => [
'server' => 'location = /private-report.pdf {
return 404;
}
',
],
]);
$data = $response->json();const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/nginx-rules/validate', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
content: {
server: 'location = /private-report.pdf {\n return 404;\n}\n',
},
}),
});
// An answer with no body (204) has nothing to parse.
const text = await res.text();
const data = text && JSON.parse(text);import os
import requests
res = requests.post(
"https://manage.corefinity.com/api/corestack/sites/1042/nginx-rules/validate",
headers={
"Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
"Accept": "application/json",
},
json={
"content": {
"server": "location = /private-report.pdf {\n return 404;\n}\n",
},
},
)
data = res.json() if res.content else None{
"diagnostics": [],
"policy_version": 6,
"test": {
"id": 9,
"status": "queued"
}
}{
"message": "Unauthenticated."
}{
"code": "company_unavailable",
"message": "Your company is unavailable.",
"reason": "company_unavailable"
}{
"code": "feature_off",
"message": "Not found.",
"reason": "feature_off"
}{
"code": "managed_elsewhere",
"message": "This site is managed by another control panel",
"reason": "managed_elsewhere"
}{
"code": "too_large",
"hook": "server",
"max_bytes": 65536,
"message": "The server hook is larger than 64 KB.",
"reason": "too_large"
}{
"code": "invalid",
"errors": {
"sandbox": [
"sandbox is true or false."
]
},
"field": "sandbox",
"message": "sandbox is true or false.",
"reason": "invalid"
}{
"code": "rate_limited",
"message": "Too many attempts on this environment. Try again shortly.",
"reason": "rate_limited",
"retry_after_seconds": 60
}{
"message": "Server Error"
}