Skip to content

Configuring Subdomain Manager

All settings are on one page: Subdomain Manager in the admin sidebar. The page has four boxes: Global Settings, Add New Domain, Configured Domains and Active Subdomain Allocations.

Cloudflare setup

The addon needs two things from Cloudflare.

An API token. The addon sends it as Authorization: Bearer <token> and calls these endpoints of the Cloudflare API (https://api.cloudflare.com/client/v4):

Call When
GET /zones Test Connection
POST /zones/{zone_id}/dns_records/batch Creating, updating and deleting records
GET /zones/{zone_id}/dns_records?comment=... Finding the records of a subdomain before an update or deletion

The token therefore needs permission to read and edit DNS records in every zone you add as a domain. The addon's README recommends creating the token from Cloudflare's Edit zone DNS template and limiting it to the zones you use.

Warning

The field is labelled Cloudflare API Token / Global API Key, but the value is always sent as a bearer token and no account e-mail address is sent with it. Enter an API token.

The zone ID of each domain. Cloudflare shows it on the overview page of the domain. You enter it once per domain under Add New Domain.

One token is used for all domains.

Global settings

Setting Type Default What it does
Cloudflare API Token / Global API Key Password field, required Empty The token for all Cloudflare calls. Once a token is saved, the field shows <hidden>. Leave <hidden> in place to keep the saved token, or replace it to store a new one.
Max Subdomains Per Server Whole number, 0 or higher 5 The highest number of subdomains one server may have. The same limit applies to every server.
Word Blacklist Text, optional Empty Comma-separated list of names that cannot be registered, for example admin, api, mail.

Click Save Settings to store all three values. The page confirms with Applied new settings.

Notes on how the code treats these values:

  • The token is required on every save. You cannot save the limit or the blacklist while the token field is empty.
  • The token is stored as plain text in the table subdomain_manager_config.
  • The limit is global. There is no limit per server, per egg or per user.
  • A limit of 0 blocks all new subdomains. The hint under the field says "Set to 0 for unlimited.", but the code refuses a new subdomain as soon as the server's count is equal to or above the limit, and the server page shows "Subdomains cannot be created for this server because the subdomain limit is set to 0." There is no unlimited value. Enter a high number instead.
  • After saving 0, the field shows 5 again. The stored value is still 0. If you save the form again without changing the field, the limit becomes 5.
  • The blacklist matches whole names only. A word blocks a subdomain only if the full name equals it. Upper and lower case are ignored, and spaces around the commas are removed. admin blocks admin and Admin, but not admin1 or myadmin.
  • Lowering the limit does not delete existing subdomains. Servers above the new limit keep theirs and cannot add more.

Test Connection

Test Connection is available once a token is saved. It requests the zone list from Cloudflare with the saved token and shows Successfully connected to Cloudflare API. or Failed to connect to Cloudflare API. It does not check a zone ID and does not create any record.

Domains

Add a domain

Field Type What it does
Domain FQDN Text, required The domain under which subdomains are created, for example example.com.
Cloudflare Zone ID Text, required The ID of the Cloudflare zone that receives the records.
Enabled Eggs Multiple choice The eggs whose servers may use this domain.

Click Add Domain. The domain is stored with the default record template.

  • A domain with no egg selected is not offered to any server.
  • The domain and the zone ID are not checked against Cloudflare when you add them. A wrong zone ID shows up only when a customer tries to create a subdomain.
  • The Domain FQDN can itself be a subdomain of your zone, for example mc.example.com, as long as the zone ID is the one of the zone that contains it.

Edit a domain

Click the pencil button in Configured Domains. You can change Enabled Eggs and Cloudflare API Data (JSON). Domain and Cloudflare Zone ID are read-only. To change them, delete the domain and add it again.

Changes to the eggs or the template apply to subdomains created or updated afterwards. Existing DNS records are not rewritten.

Delete a domain

Click the trash button and confirm. The page shows Domain deletion queued. A queued job then removes the Cloudflare records of every subdomain on that domain, deletes the subdomains and finally deletes the domain. See Usage.

DNS record template

Each domain has its own template in Cloudflare API Data (JSON). When a subdomain is created, the addon fills in the placeholders and sends the result as the body of POST /zones/{zone_id}/dns_records/batch. The records to create are listed under posts.

The default template for a new domain is:

{
    "posts": [
        {
            "type": "A",
            "name": "{subdomain}.{domain}",
            "content": "{ip_alias_forceip}",
            "comment": "{comment}",
            "ttl": 120,
            "proxied": false
        },
        {
            "type": "SRV",
            "name": "_minecraft._tcp.{subdomain}.{domain}",
            "data": {
                "priority": 0,
                "weight": 5,
                "port": "{port}",
                "target": "{subdomain}.{domain}"
            },
            "comment": "{comment}",
            "ttl": 120
        }
    ]
}
Placeholder Replaced with
{subdomain} The name the user entered
{domain} The domain as you entered it in Domain FQDN
{ip} The IP address of the chosen allocation
{ip_alias} The allocation's IP alias, or its IP address if it has no alias
{ip_alias_forceip} The IPv4 address that the alias resolves to, or the allocation's IP address if it has no alias. If the alias cannot be resolved, the alias itself is used.
{port} The port of the chosen allocation
{comment} subdomainmanager.subdomain_id=<ID>, where <ID> is the ID of the subdomain in the panel

Warning

Keep "comment": "{comment}" on every record in the template. The addon finds the records of a subdomain only by this comment. Records without it are never updated or deleted by the addon and stay in your Cloudflare zone.

The template must be valid JSON. Otherwise the page shows Invalid JSON provided for API data. and nothing is saved. The content of the JSON is not checked beyond that. An entry that Cloudflare rejects makes every subdomain creation on this domain fail.

To create different records for different kinds of servers, add one domain per kind, select the matching eggs and edit its template. For example, change _minecraft._tcp to the SRV service of another game, or remove the SRV entry for servers that only need an A record.

Subuser permissions

The block you added to app/Models/Permission.php adds these permissions to the subuser editor. The server owner and panel administrators have all of them.

Permission Allows
subdomains.read Open the Subdomains tab and see the list
subdomains.create Create a subdomain
subdomains.update Change the allocation of a subdomain
subdomains.delete Delete a subdomain