Skip to content

Commit 8831312

Browse files
committed
Merge #441 - Enable SSL for all server
Pull-request: #441 Signed-off-by: William Desportes <[email protected]>
2 parents 2335c31 + 928a52e commit 8831312

File tree

9 files changed

+55
-0
lines changed

9 files changed

+55
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,21 @@ In order to keep your sessions active between container updates you will need to
158158
-v /some/local/directory/sessions:/sessions:rw
159159
```
160160

161+
## Connect to the database over SSL
162+
163+
Set the variable ``PMA_SSL`` to `1` to enable SSL usage from phpMyAdmin to the MySQL server.
164+
The default value is `0`.
165+
The variable ``PMA_SSLS`` can be used as a comma seperated sequence of `0` and `1` where multiple hosts are mentioned.
166+
Values order must follow the ``PMA_HOSTS`` and will be computed accordingly.
167+
168+
```sh
169+
docker run --name phpmyadmin -d -e PMA_HOSTS=sslhost -e PMA_SSL=1 -p 8080:80 phpmyadmin:latest
170+
```
171+
172+
```sh
173+
docker run --name phpmyadmin -d -e PMA_HOSTS='sslhost,nosslhost' -e PMA_SSLS='1,0' -p 8080:80 phpmyadmin:latest
174+
```
175+
161176
## Environment variables summary
162177

163178
* ``PMA_ARBITRARY`` - when set to 1 connection to the arbitrary server will be allowed
@@ -169,6 +184,8 @@ In order to keep your sessions active between container updates you will need to
169184
* ``PMA_PORTS`` - define comma separated list of ports of the MySQL servers
170185
* ``PMA_SOCKET`` - define socket file for the MySQL connection
171186
* ``PMA_SOCKETS`` - define comma separated list of socket files for the MySQL connections
187+
* ``PMA_SSL`` - when set to 1, defines SSL usage for the MySQL connection
188+
* ``PMA_SSLS`` - comma separated list of `0` and `1` defining SSL usage for the corresponding MySQL connections
172189
* ``PMA_USER`` and ``PMA_PASSWORD`` - define username and password to use only with the `config` authentication method
173190
* ``PMA_ABSOLUTE_URI`` - the full URL to phpMyAdmin. Sometimes needed when used in a reverse-proxy configuration. Don't set this unless needed. See [documentation](https://docs.phpmyadmin.net/en/latest/config.html#cfg_PmaAbsoluteUri).
174191
* ``PMA_CONFIG_BASE64`` - if set, this option will override the default `config.inc.php` with the base64 decoded contents of the variable
@@ -206,6 +223,8 @@ docker run --name phpmyadmin -d -e PMA_PASSWORD_FILE=/run/secrets/db_password.tx
206223
- `PMA_CONTROLHOST`
207224
- `PMA_CONTROLUSER`
208225
- `PMA_CONTROLPASS`
226+
- `PMA_SSL`
227+
- `PMA_SSLS`
209228

210229
## Run the E2E tests for this docker image
211230

apache/config.inc.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
'MEMORY_LIMIT',
2828
'PMA_UPLOADDIR',
2929
'PMA_SAVEDIR',
30+
'PMA_SSL',
31+
'PMA_SSLS',
3032
];
3133

3234
foreach ($vars as $var) {
@@ -63,10 +65,12 @@
6365
$hosts = [$_ENV['PMA_HOST']];
6466
$verbose = [$_ENV['PMA_VERBOSE']];
6567
$ports = [$_ENV['PMA_PORT']];
68+
$ssls = [$_ENV['PMA_SSL']];
6669
} elseif (! empty($_ENV['PMA_HOSTS'])) {
6770
$hosts = array_map('trim', explode(',', $_ENV['PMA_HOSTS']));
6871
$verbose = array_map('trim', explode(',', $_ENV['PMA_VERBOSES']));
6972
$ports = array_map('trim', explode(',', $_ENV['PMA_PORTS']));
73+
$ssls = array_map('trim', explode(',', $_ENV['PMA_SSLS']));
7074
}
7175

7276
if (! empty($_ENV['PMA_SOCKET'])) {
@@ -77,6 +81,9 @@
7781

7882
/* Server settings */
7983
for ($i = 1; isset($hosts[$i - 1]); $i++) {
84+
if (isset($ssls[$i - 1]) && $ssls[$i - 1] === '1') {
85+
$cfg['Servers'][$i]['ssl'] = $ssls[$i - 1];
86+
}
8087
$cfg['Servers'][$i]['host'] = $hosts[$i - 1];
8188
if (isset($verbose[$i - 1])) {
8289
$cfg['Servers'][$i]['verbose'] = $verbose[$i - 1];

apache/docker-entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,7 @@ get_docker_secret PMA_HOST
5858
get_docker_secret PMA_CONTROLHOST
5959
get_docker_secret PMA_CONTROLUSER
6060
get_docker_secret PMA_CONTROLPASS
61+
get_docker_secret PMA_SSL
62+
get_docker_secret PMA_SSLS
6163

6264
exec "$@"

config.inc.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
'MEMORY_LIMIT',
2828
'PMA_UPLOADDIR',
2929
'PMA_SAVEDIR',
30+
'PMA_SSL',
31+
'PMA_SSLS',
3032
];
3133

3234
foreach ($vars as $var) {
@@ -63,10 +65,12 @@
6365
$hosts = [$_ENV['PMA_HOST']];
6466
$verbose = [$_ENV['PMA_VERBOSE']];
6567
$ports = [$_ENV['PMA_PORT']];
68+
$ssls = [$_ENV['PMA_SSL']];
6669
} elseif (! empty($_ENV['PMA_HOSTS'])) {
6770
$hosts = array_map('trim', explode(',', $_ENV['PMA_HOSTS']));
6871
$verbose = array_map('trim', explode(',', $_ENV['PMA_VERBOSES']));
6972
$ports = array_map('trim', explode(',', $_ENV['PMA_PORTS']));
73+
$ssls = array_map('trim', explode(',', $_ENV['PMA_SSLS']));
7074
}
7175

7276
if (! empty($_ENV['PMA_SOCKET'])) {
@@ -77,6 +81,9 @@
7781

7882
/* Server settings */
7983
for ($i = 1; isset($hosts[$i - 1]); $i++) {
84+
if (isset($ssls[$i - 1]) && $ssls[$i - 1] === '1') {
85+
$cfg['Servers'][$i]['ssl'] = $ssls[$i - 1];
86+
}
8087
$cfg['Servers'][$i]['host'] = $hosts[$i - 1];
8188
if (isset($verbose[$i - 1])) {
8289
$cfg['Servers'][$i]['verbose'] = $verbose[$i - 1];

docker-entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,7 @@ get_docker_secret PMA_HOST
5858
get_docker_secret PMA_CONTROLHOST
5959
get_docker_secret PMA_CONTROLUSER
6060
get_docker_secret PMA_CONTROLPASS
61+
get_docker_secret PMA_SSL
62+
get_docker_secret PMA_SSLS
6163

6264
exec "$@"

fpm-alpine/config.inc.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
'MEMORY_LIMIT',
2828
'PMA_UPLOADDIR',
2929
'PMA_SAVEDIR',
30+
'PMA_SSL',
31+
'PMA_SSLS',
3032
];
3133

3234
foreach ($vars as $var) {
@@ -63,10 +65,12 @@
6365
$hosts = [$_ENV['PMA_HOST']];
6466
$verbose = [$_ENV['PMA_VERBOSE']];
6567
$ports = [$_ENV['PMA_PORT']];
68+
$ssls = [$_ENV['PMA_SSL']];
6669
} elseif (! empty($_ENV['PMA_HOSTS'])) {
6770
$hosts = array_map('trim', explode(',', $_ENV['PMA_HOSTS']));
6871
$verbose = array_map('trim', explode(',', $_ENV['PMA_VERBOSES']));
6972
$ports = array_map('trim', explode(',', $_ENV['PMA_PORTS']));
73+
$ssls = array_map('trim', explode(',', $_ENV['PMA_SSLS']));
7074
}
7175

7276
if (! empty($_ENV['PMA_SOCKET'])) {
@@ -77,6 +81,9 @@
7781

7882
/* Server settings */
7983
for ($i = 1; isset($hosts[$i - 1]); $i++) {
84+
if (isset($ssls[$i - 1]) && $ssls[$i - 1] === '1') {
85+
$cfg['Servers'][$i]['ssl'] = $ssls[$i - 1];
86+
}
8087
$cfg['Servers'][$i]['host'] = $hosts[$i - 1];
8188
if (isset($verbose[$i - 1])) {
8289
$cfg['Servers'][$i]['verbose'] = $verbose[$i - 1];

fpm-alpine/docker-entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,7 @@ get_docker_secret PMA_HOST
5050
get_docker_secret PMA_CONTROLHOST
5151
get_docker_secret PMA_CONTROLUSER
5252
get_docker_secret PMA_CONTROLPASS
53+
get_docker_secret PMA_SSL
54+
get_docker_secret PMA_SSLS
5355

5456
exec "$@"

fpm/config.inc.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
'MEMORY_LIMIT',
2828
'PMA_UPLOADDIR',
2929
'PMA_SAVEDIR',
30+
'PMA_SSL',
31+
'PMA_SSLS',
3032
];
3133

3234
foreach ($vars as $var) {
@@ -63,10 +65,12 @@
6365
$hosts = [$_ENV['PMA_HOST']];
6466
$verbose = [$_ENV['PMA_VERBOSE']];
6567
$ports = [$_ENV['PMA_PORT']];
68+
$ssls = [$_ENV['PMA_SSL']];
6669
} elseif (! empty($_ENV['PMA_HOSTS'])) {
6770
$hosts = array_map('trim', explode(',', $_ENV['PMA_HOSTS']));
6871
$verbose = array_map('trim', explode(',', $_ENV['PMA_VERBOSES']));
6972
$ports = array_map('trim', explode(',', $_ENV['PMA_PORTS']));
73+
$ssls = array_map('trim', explode(',', $_ENV['PMA_SSLS']));
7074
}
7175

7276
if (! empty($_ENV['PMA_SOCKET'])) {
@@ -77,6 +81,9 @@
7781

7882
/* Server settings */
7983
for ($i = 1; isset($hosts[$i - 1]); $i++) {
84+
if (isset($ssls[$i - 1]) && $ssls[$i - 1] === '1') {
85+
$cfg['Servers'][$i]['ssl'] = $ssls[$i - 1];
86+
}
8087
$cfg['Servers'][$i]['host'] = $hosts[$i - 1];
8188
if (isset($verbose[$i - 1])) {
8289
$cfg['Servers'][$i]['verbose'] = $verbose[$i - 1];

fpm/docker-entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,7 @@ get_docker_secret PMA_HOST
5050
get_docker_secret PMA_CONTROLHOST
5151
get_docker_secret PMA_CONTROLUSER
5252
get_docker_secret PMA_CONTROLPASS
53+
get_docker_secret PMA_SSL
54+
get_docker_secret PMA_SSLS
5355

5456
exec "$@"

0 commit comments

Comments
 (0)