Make the port auto-assignment range customizable.

This commit is contained in:
Buster Neece 2019-06-18 14:41:14 -05:00
parent d94d673a2a
commit b8be1fbb9a
No known key found for this signature in database
GPG key ID: 6D9E12FF03411F4E
2 changed files with 16 additions and 2 deletions

View file

@ -17,6 +17,17 @@ PREFER_RELEASE_BUILDS=false
# Valid options: true, false
COMPOSER_PLUGIN_MODE=false
# The minimum port number to use when automatically assigning ports to a station.
# By default, this matches the first forwarded port on the "stations" container.
# You can modify this variable if your station port range is different.
# Be sure to also forward the necessary ports via `docker-compose.yml`
# (and nginx, if you want to use the built-in port-80/443 proxy)!
AUTO_ASSIGN_PORT_MIN=8000
# The maximum port number to use when automatically assigning ports to a station.
# See AUTO_ASSIGN_PORT_MIN.
AUTO_ASSIGN_PORT_MAX=8499
#
# Database Configuration
# --

View file

@ -292,8 +292,11 @@ class Configuration
// Iterate from port 8000 to 9000, in increments of 10
$protected_ports = [8080];
for($port = 8000; $port < 9000; $port += 10) {
if (in_array($port, $protected_ports)) {
$port_min = (int)($_ENV['AUTO_ASSIGN_PORT_MIN'] ?? 8000);
$port_max = (int)($_ENV['AUTO_ASSIGN_PORT_MAX'] ?? 8499);
for($port = $port_min; $port <= $port_max; $port += 10) {
if (in_array($port, $protected_ports, true)) {
continue;
}