Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PSM_BASE_URL as possible environment variable #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

brtwrst
Copy link

@brtwrst brtwrst commented Aug 4, 2021

I encountered the problem described here: phpservermon/phpservermon#1140
and the solution is to add a PSM_BASE_URL setting to the config.php.

Because the config.php is automatically created on each container start, i decided to make it configurable via an environment variable.

If the variable is not set, the config.php is not changed.
If the variable is set the line define('PSM_BASE_URL', '<content of the env-variable>'); will be added to the config.php on container start.

brtwrst added 3 commits August 4, 2021 08:04
for PSM instances running behind a reverse proxy with https
the PSM_BASE_URL configuration in the config.php is required
to prevent browsers from warning about insecure forms when
editing/adding servers or users.
see phpservermon/phpservermon#1140
This commit will add the line

define('PSM_BASE_URL', 'https://[...]');

to the config-php on container startup if the PSM_BASE_URL
environment Variable is set/passed.
for some reason when i pulled the repo and built the container,
the maria-wait.sh file did not have the execute bit set and
the container failed to start.

excplicitly setting the execute bit in the dockerfile fixes this problem
@@ -20,6 +20,10 @@ define('PSM_DB_PREFIX', '${MYSQL_DATABASE_PREFIX}');
?>
EOF

if [ ${PSM_BASE_URL} != false ]; then
sed -i "s|?>|define('PSM_BASE_URL', '$PSM_BASE_URL');\n?>|1" ${APACHE_DOCUMENT_ROOT}/config.php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the 1 for? I've never seen that before.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it means replace first ocurrence only
it was in the sed command I copied from so I just left it.
g would also work obviously

Copy link

@casperklein casperklein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@trudslev
Copy link

Can this be merged in, please? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants