From 10859bfbf792b97f506eb3861664f06586f5fa23 Mon Sep 17 00:00:00 2001 From: Ali Mahdavi Date: Tue, 20 Feb 2024 17:54:00 +0300 Subject: [PATCH 1/2] move nginx.conf under www/html/ --- Dockerfile | 2 +- docker-entrypoint.sh | 4 ++-- nginx.conf | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 55664d4..14da30d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -207,4 +207,4 @@ EXPOSE 2222/tcp ENTRYPOINT ["/usr/local/docker-entrypoint.sh"] # Start PHP-FPM and Nginx servers -CMD /usr/local/php-fpm.sh & nginx -g "daemon off;" -c "/var/www/nginx.conf" & /usr/sbin/sshd -D +CMD /usr/local/php-fpm.sh & nginx -g "daemon off;" -c "/var/www/html/nginx.conf" & /usr/sbin/sshd -D diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index cbedcdb..1153d7d 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -34,12 +34,12 @@ fi #copy nginx config file_path="/etc/nginx/nginx.conf" -dst_path="/var/www/nginx.conf" +dst_path="/var/www/html/nginx.conf" if [ -f "$dst_path" ]; then echo "$dst_path already exist." else echo "Creating $dst_path..." - cp "$file_path" "/var/www/" + cp "$file_path" "/var/www/html/" echo "Nginx file copied successfully." fi diff --git a/nginx.conf b/nginx.conf index f608d38..27b3954 100644 --- a/nginx.conf +++ b/nginx.conf @@ -69,6 +69,10 @@ http { location = /xmlrpc.php { deny all; } + # Block nginx.conf + location = /nginx.conf { + deny all; + } } From b369fb28825fdc927eb9976ba84af1584015ec6a Mon Sep 17 00:00:00 2001 From: Ali Mahdavi Date: Tue, 20 Feb 2024 18:25:24 +0300 Subject: [PATCH 2/2] add extra check for wp existance --- docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 1153d7d..79d4d2b 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -57,7 +57,7 @@ for contentPath in \ sourceTarArgs+=( --exclude "./$contentPath" ) fi done -if [ -d "/var/www/html/wp-admin" ]; then +if [ -d "/var/www/html/wp-admin" ] && [ -f "/var/www/html/wp-config.php" ]; then echo "Wordpress already there skipping..." else tar "${sourceTarArgs[@]}" . | tar "${targetTarArgs[@]}"