Skip to main content

Show your sentry's IP address in cPanel

When your sites are behind stillorigin, their DNS points at your sentries. The General Information panel on cPanel's Tools page still shows the server's own Shared IP Address. Customers often copy that address into their DNS, which sends visitors straight to the server and around your sentries.

cPanel has no setting that changes the address it shows. WHM › cPanel › Customization only changes logos, colours, the help links and the public contact details. What cPanel does support is content includes: small files you add on the server that put your own HTML, styles and JavaScript into the cPanel interface. This guide uses them to:

  1. add a notice above the General Information panel that tells customers which address to use for their website's DNS;
  2. optionally, show your sentry's address (or a short note) in place of the shared IP address on that page;
  3. put the files back automatically after a cPanel update.

stillorigin doesn't write these files for you. You add them on the cPanel server yourself, and you should test the result with a test account on your cPanel version before your customers see it. With the WHM plugin, coming with the next origin agent release, the origin agent puts your copy back after every cPanel update, so you can skip step 5.

This only changes what cPanel shows

The server's IP address doesn't change, and no DNS record is changed either. Other cPanel pages, cPanel's APIs and services that don't go through your sentries, such as email, still use the server's own address. Hiding the address isn't a security control: to stop visitors going around your sentries, let only your sentries through the origin's firewall.

Before you start​

You need:

  • a cPanel & WHM server with the Jupiter theme, and root access to it over SSH;
  • the public IP address your customers' websites should point at. That's your cluster's VIP if it has one, otherwise each sentry's Public IP, shown on the sentry's page in the portal (see Point DNS at your sentries). Finding a domain's sentries in the API can also return these addresses for any domain;
  • a test cPanel account on the server, so you can check the result before your customers see it.

The examples use 203.0.113.5 for the server's shared IP address and 198.51.100.21 for the sentry. Use your own addresses.

If the sites on this server are served by more than one cluster, there isn't one address that's right for everyone. Use a note such as "see your welcome email" instead of an address.

1. Create the content includes folder​

cPanel reads content includes from /var/cpanel/customizations/content_includes. The folder doesn't exist until you create it, and only root can add files to it.

Keep your own master copy of the file somewhere else, so you can put it back if it's ever removed:

mkdir -p /var/cpanel/customizations/content_includes
mkdir -p /root/stillorigin-cpanel/content_includes

2. Add a notice above General Information​

On the Jupiter theme, cPanel can include the file cpanel_jupiter_tools_general_information_before.html.tt immediately above the General Information panel on the Tools page. That's the include this guide uses. Include names can differ between cPanel versions, so check with your test account that the notice appears where you expect.

Create it in your master copy folder, for example /root/stillorigin-cpanel/content_includes/cpanel_jupiter_tools_general_information_before.html.tt.

Add your notice. For example:

<div style="border:1px solid #c7d7f0;background:#f2f7ff;border-radius:6px;padding:12px 14px;margin-bottom:12px">
<strong>Pointing your website's DNS?</strong><br>
Set your domain's A record to <strong>198.51.100.21</strong>.
Your website is protected by stillorigin, so don't use the server's shared IP address for it.
</div>

If your cluster has more than one sentry and no VIP, list each sentry's address, one A record each.

3. Optional: show the sentry's address instead of the shared IP​

cPanel doesn't document the page markup, so you can't change the Shared IP Address value in a template. A short script in the same file can change the text on the page after it loads instead. It looks for the server's shared IP address in the text of the Tools page and shows your sentry's address (or a note) in its place. It replaces every occurrence of that address in the page text, not only the Shared IP Address line.

This swap is optional. If it doesn't work on your cPanel version, keep the notice on its own.

Add this below your notice, in the same file, and change the two addresses at the top:

<script>
(function () {
var serverIp = "203.0.113.5"; // the shared IP address cPanel shows
var shown = "198.51.100.21"; // what to show instead, for example a sentry address or "see your welcome email"

function swap(root) {
if (!root) return;
var walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
var node;
while ((node = walker.nextNode())) {
if (node.nodeValue.indexOf(serverIp) !== -1) node.nodeValue = node.nodeValue.split(serverIp).join(shown);
}
}

function start() {
swap(document.body);
// The Tools page fills some panels in after it loads, so keep watching for new text.
new MutationObserver(function (changes) {
changes.forEach(function (c) {
if (c.type === "characterData") swap(c.target.parentNode);
c.addedNodes.forEach(function (n) { swap(n.nodeType === 3 ? n.parentNode : n); });
});
}).observe(document.body, { childList: true, characterData: true, subtree: true });
}

if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", start);
else start();
})();
</script>

This file is included on the Tools page, so the script only runs there. It changes what the browser shows; it doesn't change the address cPanel itself uses or sends.

4. Copy the file into place and test it​

install -o root -g root -m 0644 \
/root/stillorigin-cpanel/content_includes/cpanel_jupiter_tools_general_information_before.html.tt \
/var/cpanel/customizations/content_includes/

Then sign in to cPanel as your test account and open the Tools page. You should now see:

  • your notice immediately above General Information;
  • if you added the script, Shared IP Address showing your sentry's address or your note.

If the notice shows but the address doesn't change, find out how your cPanel version shows the address: right-click the shared IP address on the page and choose Inspect. If the address isn't plain text there, for example because it's inside a link or an attribute, the script won't change it. Keep the notice on its own.

If the notice doesn't appear at all, check the include filename for your cPanel version, and that the file is in /var/cpanel/customizations/content_includes/.

To find any other cPanel pages that show the shared IP address, search the theme for the wording you see on the page, for example:

grep -rl "Shared IP Address" /usr/local/cpanel/base/frontend/jupiter/ | head

Don't edit the files you find there. They belong to cPanel and are replaced when cPanel updates.

5. Put the file back after cPanel updates​

The origin agent can do this for you

With the WHM plugin (coming with the next origin agent release), the origin agent registers its own System::upcp hook and copies the files from /root/stillorigin-cpanel/content_includes/ back into place after every cPanel update. Keep your master copy in that folder and you don't need the script below. If you already registered the script, you can keep it or remove it: the two don't clash.

Without the WHM plugin, register the hook yourself. cPanel says its update process can sometimes overwrite customised files with its own default versions, and recommends a Standardized Hook to put them back. Register a hook on the System::upcp event, at the post stage, so it runs as root after every cPanel update.

Create the script at /root/stillorigin-cpanel/reapply.sh:

#!/bin/bash
# Puts the stillorigin cPanel notice back after a cPanel update.
# cPanel passes event details on standard input. They aren't needed here.
[ -t 0 ] || cat > /dev/null

SRC=/root/stillorigin-cpanel/content_includes
DST=/var/cpanel/customizations/content_includes
mkdir -p "$DST"
for f in "$SRC"/*.html.tt; do
[ -e "$f" ] || continue
if ! cmp -s "$f" "$DST/$(basename "$f")"; then
install -o root -g root -m 0644 "$f" "$DST/"
fi
done
exit 0

Make it executable, run it once by hand, and register it with cPanel's manage_hooks tool:

chmod 0700 /root/stillorigin-cpanel/reapply.sh
/root/stillorigin-cpanel/reapply.sh
/usr/local/cpanel/bin/manage_hooks add script /root/stillorigin-cpanel/reapply.sh --manual --category System --event upcp --stage post

Check it's registered:

/usr/local/cpanel/bin/manage_hooks list

You should see it under System, upcp, stage post. If the command's options differ on your cPanel version, check cPanel's documentation for Standardized Hooks.

After a cPanel update, check the Tools page again with your test account. The hook is meant to put your file back, but an update can also change how the page is laid out. If the address stops being replaced, or the notice goes missing, use the notice on its own until you've checked the page with Inspect again.

Changing or removing it​

  • To change the notice or the address: edit the file in /root/stillorigin-cpanel/content_includes/ and run /root/stillorigin-cpanel/reapply.sh (with the WHM plugin and no script, copy it into /var/cpanel/customizations/content_includes/ with the install command in step 4).
  • To remove it: unregister the hook (if you registered the script), then delete the file from both folders. With the WHM plugin, delete the master copy too, or the origin agent puts the notice back after the next cPanel update:
/usr/local/cpanel/bin/manage_hooks delete script /root/stillorigin-cpanel/reapply.sh --manual --category System --event upcp --stage post
rm /var/cpanel/customizations/content_includes/cpanel_jupiter_tools_general_information_before.html.tt
rm -r /root/stillorigin-cpanel