Skip to content

Commit 3ee7b7c

Browse files
committed
Add ability to mark a node as being over a proxy
1 parent 801aae9 commit 3ee7b7c

File tree

7 files changed

+86
-21
lines changed

7 files changed

+86
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1111
* Added new scripts for service options that allows installation of software in a privileged Docker container on the node prior to marking a server as installed.
1212
* Added ability to reinstall a server using the currently assigned service and option.
1313
* Added ability to change a server's service and service option, as well as change pack assignments and other management services in that regard.
14+
* Added support for using a proxy such as Cloudflare with a node connection. Previously there was no way to tell the panel to connect over SSL without marking the Daemon as also using SSL.
1415

1516
### Changed
1617
* Environment setting commands now attempt to auto-quote strings with spaces in them, as well as comment lines that are edited to avoid manual changes being overwritten.

app/Http/Controllers/Admin/NodesController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function store(Request $request)
8888
]),
8989
$request->intersect([
9090
'name', 'location_id', 'fqdn',
91-
'scheme', 'memory', 'disk',
91+
'scheme', 'memory', 'disk', 'behind_proxy',
9292
'daemonBase', 'daemonSFTP', 'daemonListen',
9393
])
9494
));
@@ -218,7 +218,7 @@ public function updateSettings(Request $request, $id)
218218
'public', 'disk_overallocate', 'memory_overallocate',
219219
]),
220220
$request->intersect([
221-
'name', 'location_id', 'fqdn',
221+
'name', 'location_id', 'fqdn', 'behind_proxy',
222222
'scheme', 'memory', 'disk', 'upload_size',
223223
'reset_secret', 'daemonSFTP', 'daemonListen',
224224
])

app/Models/Node.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Node extends Model
5959
'disk' => 'integer',
6060
'daemonListen' => 'integer',
6161
'daemonSFTP' => 'integer',
62+
'behind_proxy' => 'boolean',
6263
];
6364

6465
/**
@@ -68,8 +69,8 @@ class Node extends Model
6869
*/
6970
protected $fillable = [
7071
'public', 'name', 'location_id',
71-
'fqdn', 'scheme', 'memory',
72-
'memory_overallocate', 'disk',
72+
'fqdn', 'scheme', 'behind_proxy',
73+
'memory', 'memory_overallocate', 'disk',
7374
'disk_overallocate', 'upload_size',
7475
'daemonSecret', 'daemonBase',
7576
'daemonSFTP', 'daemonListen',
@@ -121,7 +122,7 @@ public function getConfigurationAsJson($pretty = false)
121122
'host' => '0.0.0.0',
122123
'listen' => $this->daemonListen,
123124
'ssl' => [
124-
'enabled' => $this->scheme === 'https',
125+
'enabled' => (! $this->behind_proxy && $this->scheme === 'https'),
125126
'certificate' => '/etc/letsencrypt/live/' . $this->fqdn . '/fullchain.pem',
126127
'key' => '/etc/letsencrypt/live/' . $this->fqdn . '/privkey.pem',
127128
],
@@ -143,7 +144,7 @@ public function getConfigurationAsJson($pretty = false)
143144
'count' => 3,
144145
],
145146
'remote' => [
146-
'base' => config('app.url'),
147+
'base' => route('index'),
147148
'download' => route('remote.download'),
148149
'installed' => route('remote.install'),
149150
],

app/Repositories/NodeRepository.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function create(array $data)
5252
'public' => 'required|numeric|between:0,1',
5353
'fqdn' => 'required|string|unique:nodes,fqdn',
5454
'scheme' => 'required|regex:/^(http(s)?)$/',
55+
'behind_proxy' => 'required|boolean',
5556
'memory' => 'required|numeric|min:1',
5657
'memory_overallocate' => 'required|numeric|min:-1',
5758
'disk' => 'required|numeric|min:1',
@@ -109,6 +110,7 @@ public function update($id, array $data)
109110
'public' => 'numeric|between:0,1',
110111
'fqdn' => 'string|unique:nodes,fqdn,' . $id,
111112
'scheme' => 'regex:/^(http(s)?)$/',
113+
'behind_proxy' => 'boolean',
112114
'memory' => 'numeric|min:1',
113115
'memory_overallocate' => 'numeric|min:-1',
114116
'disk' => 'numeric|min:1',
@@ -166,7 +168,7 @@ public function update($id, array $data)
166168
'web' => [
167169
'listen' => $node->daemonListen,
168170
'ssl' => [
169-
'enabled' => ($node->scheme === 'https'),
171+
'enabled' => (! $node->behind_proxy && $node->scheme === 'https'),
170172
],
171173
],
172174
'sftp' => [
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('nodes', function (Blueprint $table) {
17+
$table->boolean('behind_proxy')->after('scheme')->default(false);
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
Schema::table('nodes', function (Blueprint $table) {
29+
$table->dropColumn('behind_proxy');
30+
});
31+
}
32+
}

resources/themes/pterodactyl/admin/nodes/new.blade.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,28 @@
7878
<div>
7979
<div class="radio radio-success radio-inline">
8080
<input type="radio" id="pSSLTrue" value="https" name="scheme" checked>
81-
<label for="pSSLTrue"> Enable SSL </label>
81+
<label for="pSSLTrue"> Use SSL Connection</label>
8282
</div>
8383
<div class="radio radio-danger radio-inline">
8484
<input type="radio" id="pSSLFalse" value="http" name="scheme">
85-
<label for="pSSLFalse"> Disable SSL </label>
85+
<label for="pSSLFalse"> Use HTTP Connection</label>
8686
</div>
8787
</div>
88-
<p class="text-muted small">SSL should only be disabled if this node is assigned an IP address as the FQDN and not an actual FQDN. Disabling SSL could allow a malicious user to intercept traffic between the panel and the daemon potentially exposing sensitive information.</p>
88+
<p class="text-muted small">In most cases you should select to use a SSL connection. If using an IP Address or you do not wish to use SSL at all, select a HTTP connection.</p>
8989
</div>
9090
<div class="form-group">
91-
<label for="pDaemonBase" class="form-label">Daemon Server File Directory</label>
92-
<input type="text" name="daemonBase" id="pDaemonBase" class="form-control" value="/srv/daemon-data" />
93-
<p class="text-muted small">Enter the directory where server files should be stored. <strong>If you use OVH you should check your partition scheme. You may need to use <code>/home/daemon-data</code> to have enough space.</strong></p>
91+
<label class="form-label">Behind Proxy</label>
92+
<div>
93+
<div class="radio radio-success radio-inline">
94+
<input type="radio" id="pProxyFalse" value="0" name="behind_proxy" checked>
95+
<label for="pProxyFalse"> Not Behind Proxy </label>
96+
</div>
97+
<div class="radio radio-info radio-inline">
98+
<input type="radio" id="pProxyTrue" value="1" name="behind_proxy">
99+
<label for="pProxyTrue"> Behind Proxy </label>
100+
</div>
101+
</div>
102+
<p class="text-muted small">If you are running the daemon behind a proxy such as Cloudflare, select this to have the daemon skip looking for certificates on boot.</p>
94103
</div>
95104
</div>
96105
</div>
@@ -102,6 +111,11 @@
102111
</div>
103112
<div class="box-body">
104113
<div class="row">
114+
<div class="form-group col-xs-12">
115+
<label for="pDaemonBase" class="form-label">Daemon Server File Directory</label>
116+
<input type="text" name="daemonBase" id="pDaemonBase" class="form-control" value="/srv/daemon-data" />
117+
<p class="text-muted small">Enter the directory where server files should be stored. <strong>If you use OVH you should check your partition scheme. You may need to use <code>/home/daemon-data</code> to have enough space.</strong></p>
118+
</div>
105119
<div class="form-group col-md-6">
106120
<label for="pMemory" class="form-label">Total Memory</label>
107121
<div class="input-group">

resources/themes/pterodactyl/admin/nodes/view/settings.blade.php

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,33 @@
8989
</small></p>
9090
</div>
9191
<div class="form-group col-xs-12">
92-
<label for="scheme" class="control-label"><span class="label label-warning"><i class="fa fa-power-off"></i></span> Secure Socket Layer</label>
93-
<div class="row" style="padding: 7px 0;">
94-
<div class="col-xs-6">
95-
<input type="radio" name="scheme" value="https" id="scheme_ssl" {{ (old('scheme', $node->scheme) === 'https') ? 'checked' : '' }}/> <label for="scheme_ssl" style="padding-left: 5px;">Enable HTTPS/SSL</label>
92+
<label class="form-label"><span class="label label-warning"><i class="fa fa-power-off"></i></span> Communicate Over SSL</label>
93+
<div>
94+
<div class="radio radio-success radio-inline">
95+
<input type="radio" id="pSSLTrue" value="https" name="scheme" {{ (old('scheme', $node->scheme) === 'https') ? 'checked' : '' }}>
96+
<label for="pSSLTrue"> Use SSL Connection</label>
9697
</div>
97-
<div class="col-xs-6">
98-
<input type="radio" name="scheme" value="http" id="scheme_nossl" {{ (old('scheme', $node->scheme) === 'http') ? 'checked' : '' }}/> <label for="scheme_nossl" style="padding-left: 5px;">Disable HTTPS/SSL</label>
98+
<div class="radio radio-danger radio-inline">
99+
<input type="radio" id="pSSLFalse" value="http" name="scheme" {{ (old('scheme', $node->scheme) !== 'https') ? 'checked' : '' }}>
100+
<label for="pSSLFalse"> Use HTTP Connection</label>
99101
</div>
100102
</div>
101-
<p class="text-muted"><small>You should always leave SSL enabled for nodes. Disabling SSL could allow a malicious user to intercept traffic between the panel and the daemon potentially exposing sensitive information.</small></p>
103+
<p class="text-muted small">In most cases you should select to use a SSL connection. If using an IP Address or you do not wish to use SSL at all, select a HTTP connection.</p>
104+
</div>
105+
<div class="form-group col-xs-12">
106+
<label class="form-label"><span class="label label-warning"><i class="fa fa-power-off"></i></span> Behind Proxy</label>
107+
<div>
108+
<div class="radio radio-success radio-inline">
109+
<input type="radio" id="pProxyFalse" value="0" name="behind_proxy" {{ (old('behind_proxy', $node->behind_proxy) == false) ? 'checked' : '' }}>
110+
<label for="pProxyFalse"> Not Behind Proxy </label>
111+
</div>
112+
<div class="radio radio-info radio-inline">
113+
<input type="radio" id="pProxyTrue" value="1" name="behind_proxy" {{ (old('behind_proxy', $node->behind_proxy) == true) ? 'checked' : '' }}>
114+
<label for="pProxyTrue"> Behind Proxy </label>
115+
</div>
116+
</div>
117+
<p class="text-muted small">If you are running the daemon behind a proxy such as Cloudflare, select this to have the daemon skip looking for certificates on boot.</p>
102118
</div>
103-
104119
</div>
105120
</div>
106121
</div>

0 commit comments

Comments
 (0)