Azure / wordpress-linux-appservice

MIT License
111 stars 71 forks source link

Enable / Disable phpmyadmin #147

Closed jferstl closed 4 months ago

jferstl commented 5 months ago

By default there is a public facing login page to phpmyadmin. For security reasons I would like to be able to configure the Web App in a way that either:

Is there a configuration / setting where I can achive this behaviour?

dexter-dopping-ekco commented 5 months ago

Hey @jferstl, this is our approach:

In /home/dev/startup.sh I have the following lines:

if ! grep -q '# phpmyadmin-access-restriction' /etc/nginx/conf.d/default.conf; then
  # IP whitelist for phpmyadmin access
  sed -i '/location \/phpmyadmin {/a\
  include /home/dev/allow-admins.conf; # phpmyadmin-access-restriction\
  deny all;
  ' /etc/nginx/conf.d/default.conf
fi

# ... We have a bunch more customisations

# Finally reload nginx
/usr/sbin/nginx -s reload

sed is used to modify the config. The grep at the start is to prevent the replacement from running multiple times (can be useful when rerunning startup.sh for development).

/home/dev/allow-admins.config just has lines like this:

# <Person's name>
allow 123.45.67.89;
ZubaeyrMSFT commented 4 months ago

@dexter-dopping-ekco

You can disable PhpMyAdmin by setting SETUP_PHPMYADMIN Application Setting to false in your App Service.

Reference: https://github.com/Azure/wordpress-linux-appservice/blob/main/WordPress/wordpress_phpmyadmin.md

jferstl commented 4 months ago

@ZubaeyrMSFT I read about this setting but according to the description it doesn't seem to be fittet for frequently turning the phpmyadmin on and off:

Installation of PhpMyAdmin happens only once along with the WordPress setup process. It is recommended to not change this value once the WordPress installation is complete, as it might change the routing rules

samrueby commented 4 months ago

Correct, the container only pays attention to this setting on the first initialization.