Installing Subdomain Manager¶
Subdomain Manager is not a plugin that the panel loads by itself. You copy its files into the panel, add a few lines to seven existing panel files, run the database migrations and rebuild the panel front end.
The paths below assume the panel is installed in /var/www/pterodactyl.
Warning
You edit core panel files. Make a backup of the panel directory and the database first. A panel update overwrites these files, so you have to repeat steps 2 to 8 after every panel update.
1. Copy the files¶
Copy the folders app, database and resources from the download into the panel root and merge them with the existing folders. No existing panel file is replaced. These files are added:
app/Http/Controllers/Admin/SubdomainManager/SubdomainManagerAdminController.php
app/Http/Controllers/Api/Application/SubdomainManager/SubdomainManagerApplicationController.php
app/Http/Controllers/Api/Client/Servers/SubdomainManager/SubdomainManagerController.php
app/Http/Controllers/Api/Client/Servers/SubdomainManager/SubdomainManagerDestroyRequest.php
app/Http/Controllers/Api/Client/Servers/SubdomainManager/SubdomainManagerIndexRequest.php
app/Http/Controllers/Api/Client/Servers/SubdomainManager/SubdomainManagerStoreRequest.php
app/Http/Controllers/Api/Client/Servers/SubdomainManager/SubdomainManagerUpdateRequest.php
app/Http/Controllers/Api/Client/Servers/SubdomainManager/SubdomainManagerUtils.php
app/Jobs/Server/DeleteSubdomainsJob.php
app/Models/SubdomainDomain.php
app/Models/SubdomainManagerConfig.php
app/Models/SubdomainRecord.php
database/migrations/2025_01_25_000000_create_subdomain_manager_tables.php
database/migrations/2025_03_23_115000_add_blacklisted_words_to_subdomain_manager_configs.php
resources/scripts/api/server/subdomainManager/createSubdomain.ts
resources/scripts/api/server/subdomainManager/deleteSubdomain.ts
resources/scripts/api/server/subdomainManager/getData.ts
resources/scripts/api/server/subdomainManager/updateSubdomain.ts
resources/scripts/components/server/subdomainManager/CreateSubdomainDialog.tsx
resources/scripts/components/server/subdomainManager/SubdomainManagerContainer.tsx
resources/scripts/components/server/subdomainManager/UpdateSubdomainDialog.tsx
resources/views/admin/subdomainmanager/index.blade.php
2. Edit routes/api-client.php¶
Find this line:
Route::post('/power', [Client\Servers\PowerController::class, 'index']);
Add below it:
Route::group(['prefix' => '/subdomainmanager'], function () {
Route::get('/', [Client\Servers\SubdomainManager\SubdomainManagerController::class, 'index']);
Route::post('/', [Client\Servers\SubdomainManager\SubdomainManagerController::class, 'store'])->middleware('throttle:5,1');
Route::patch('/{subdomain}', [Client\Servers\SubdomainManager\SubdomainManagerController::class, 'update'])->middleware('throttle:5,1');
Route::delete('/{subdomain}', [Client\Servers\SubdomainManager\SubdomainManagerController::class, 'destroy'])->middleware('throttle:5,1');
});
throttle:5,1 limits creating, updating and deleting to five requests per minute.
3. Edit routes/api-application.php¶
Add at the bottom of the file:
Route::group(['prefix' => '/subdomainmanager'], function () {
Route::get('/domains', [Application\SubdomainManager\SubdomainManagerApplicationController::class, 'listDomains']);
Route::get('/servers/{server_id}/subdomains/check', [Application\SubdomainManager\SubdomainManagerApplicationController::class, 'checkAvailability']);
Route::post('/servers/{server_id}/subdomains', [Application\SubdomainManager\SubdomainManagerApplicationController::class, 'store']);
Route::delete('/servers/{server_id}/subdomains/{record_id}', [Application\SubdomainManager\SubdomainManagerApplicationController::class, 'destroy']);
});
Keep the parameter name {server_id}. The controller looks the server up by its numeric ID itself.
4. Edit routes/admin.php¶
Add at the bottom of the file:
Route::group(['prefix' => 'subdomainmanager'], function () {
Route::get('/', [Admin\SubdomainManager\SubdomainManagerAdminController::class, 'index'])->name('admin.subdomainmanager');
Route::post('/config', [Admin\SubdomainManager\SubdomainManagerAdminController::class, 'saveConfig'])->name('admin.subdomainmanager.config');
Route::post('/test', [Admin\SubdomainManager\SubdomainManagerAdminController::class, 'testCloudflare'])->name('admin.subdomainmanager.test');
Route::post('/domains', [Admin\SubdomainManager\SubdomainManagerAdminController::class, 'storeDomain'])->name('admin.subdomainmanager.domains.store');
Route::put('/domains/{id}', [Admin\SubdomainManager\SubdomainManagerAdminController::class, 'updateDomain'])->name('admin.subdomainmanager.domains.update');
Route::delete('/domains/{id}', [Admin\SubdomainManager\SubdomainManagerAdminController::class, 'destroyDomain'])->name('admin.subdomainmanager.domains.destroy');
});
The route names must stay as they are. The admin page and the controller refer to them.
5. Edit resources/scripts/routers/routes.ts¶
Find the import of ServerActivityLogContainer and add this line below it:
import SubdomainManagerContainer from '@/components/server/subdomainManager/SubdomainManagerContainer';
Find the route entry for /files in the server routes and add this entry below it:
{
path: '/subdomains',
permission: 'subdomains.read',
name: 'Subdomains',
component: SubdomainManagerContainer,
},
6. Edit resources/views/layouts/admin.blade.php¶
Find the Nests sidebar item:
<li class="{{ ! starts_with(Route::currentRouteName(), 'admin.nests') ?: 'active' }}">
<a href="{{ route('admin.nests') }}"><i class="fa fa-th-large"></i> <span>Nests</span></a>
</li>
Add below it:
<li class="{{ ! starts_with(Route::currentRouteName(), 'admin.subdomainmanager') ?: 'active' }}">
<a href="{{ route('admin.subdomainmanager') }}"><i class="fa fa-globe"></i> <span>Subdomain Manager</span></a>
</li>
7. Edit app/Models/Permission.php¶
The file holds a list of permission groups, each with a description and keys. Add this block as a new group next to the existing ones:
'subdomains' => [
'description' => 'Permissions that control a user\'s ability to manage subdomains for this server.',
'keys' => [
'read' => 'Allows a user to view the created subdomains.',
'create' => 'Allows a user to create a new server subdomain.',
'update' => 'Allows a user to update the server subdomains.',
'delete' => 'Allows a user to delete an existing server subdomain.',
],
],
8. Edit app/Services/Servers/ServerDeletionService.php¶
Find public function handle(Server $server): void and add this as the first line inside the method:
\Pterodactyl\Jobs\Server\DeleteSubdomainsJob::dispatch(\Illuminate\Support\Facades\DB::table('subdomain_records')->where('server_id', $server->id)->pluck('id')->toArray());
This line queues the removal of a server's DNS records when the server is deleted.
Warning
The README that ships with the addon uses the table name server_subdomains in this line. The addon's migration creates the table as subdomain_records, and server_subdomains does not exist. Use subdomain_records as shown above. With the wrong table name the query fails and servers cannot be deleted.
9. Run the commands¶
cd /var/www/pterodactyl
php artisan migrate --force
php artisan route:clear
php artisan cache:clear
yarn build:production
php artisan migrate creates three tables:
| Table | Content |
|---|---|
subdomain_manager_config |
One row with the Cloudflare token, the limit and the blacklist |
subdomain_domains |
The domains you add, with zone ID, eggs and record template |
subdomain_records |
One row per subdomain, linked to server, domain and allocation |
yarn build:production rebuilds the panel front end so that the Subdomains tab appears.
First-time setup¶
- Create a Cloudflare API token and note the zone ID of your domain. See Cloudflare setup.
- In the admin area, open Subdomain Manager in the sidebar.
- Under Global Settings, enter the token, set Max Subdomains Per Server and click Save Settings.
- Click Test Connection. The message Successfully connected to Cloudflare API. confirms that Cloudflare accepted the token.
- Under Add New Domain, enter the domain and its zone ID, select the eggs under Enabled Eggs and click Add Domain.
Servers that use one of the selected eggs can now create subdomains on that domain.
Updating¶
The download contains no update script and no changelog. To install a newer version:
- Copy
app,databaseandresourcesover the existing files again. - Compare the route and file snippets of the new version with your panel files and adjust them if they changed.
- Run the commands from step 9 again.
Uninstalling¶
Warning
Removing the addon's files and tables does not remove DNS records from Cloudflare. If you want them gone, delete every domain under Configured Domains first and wait until the queue has processed the jobs. Each deletion removes the Cloudflare records of all subdomains on that domain.
- Remove the route groups you added to
routes/api-client.php,routes/api-application.phpandroutes/admin.php. - Remove the sidebar item from
resources/views/layouts/admin.blade.php. - Remove the
subdomainsblock fromapp/Models/Permission.php. - Remove the
DeleteSubdomainsJob::dispatchline fromapp/Services/Servers/ServerDeletionService.php. - Remove the import and the route entry from
resources/scripts/routers/routes.ts. - Delete the files listed in step 1.
-
Drop the tables in this order, because
subdomain_recordsreferencessubdomain_domains:DROP TABLE subdomain_records; DROP TABLE subdomain_domains; DROP TABLE subdomain_manager_config; -
Clear the caches and rebuild the front end:
cd /var/www/pterodactyl php artisan route:clear php artisan cache:clear yarn build:production