From 95be31300afdf2b39b92fcb51a356a3d23b57470 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Mon, 28 Apr 2025 21:33:02 +0700 Subject: [PATCH] fix docker http2 config --- .docker/openresty/entrypoint.sh | 2 ++ .docker/openresty/sites/app.conf.template | 5 +++-- .docker/openresty/sites/phpmyadmin.conf.template | 5 +++-- .docker/php/entrypoint.sh | 2 ++ docker-compose.yml | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.docker/openresty/entrypoint.sh b/.docker/openresty/entrypoint.sh index f47e75d5..1504f017 100644 --- a/.docker/openresty/entrypoint.sh +++ b/.docker/openresty/entrypoint.sh @@ -62,9 +62,11 @@ envsubst '$PHPMYADMIN_SERVER_NAME' < /etc/nginx/conf.d/sites/phpmyadmin.conf.tem if [ "$USE_HTTPS" = "0" ]; then echo_info "remove https related configuration ..." sed -i '/ssl_certificate/d' "$APP_CONF" + sed -i '/http2/d' "$APP_CONF" sed -i 's/listen.*/listen 80;/g' "$APP_CONF" sed -i '/ssl_certificate/d' "$PMA_CONF" + sed -i '/http2/d' "$PMA_CONF" sed -i 's/listen.*/listen 80;/g' "$PMA_CONF" fi diff --git a/.docker/openresty/sites/app.conf.template b/.docker/openresty/sites/app.conf.template index 8f517364..800c01e1 100644 --- a/.docker/openresty/sites/app.conf.template +++ b/.docker/openresty/sites/app.conf.template @@ -1,12 +1,13 @@ server { - listen 443 ssl http2; + listen 443 ssl; + http2 on; server_name ${NP_DOMAIN}; root /var/www/html/public; index index.php index.html; ssl_certificate /certs/fullchain.pem; - ssl_certificate_key /certs/privkey.pem; + ssl_certificate_key /certs/private.pem; location = /favicon.ico { log_not_found off; diff --git a/.docker/openresty/sites/phpmyadmin.conf.template b/.docker/openresty/sites/phpmyadmin.conf.template index 7558347a..152c73ee 100644 --- a/.docker/openresty/sites/phpmyadmin.conf.template +++ b/.docker/openresty/sites/phpmyadmin.conf.template @@ -1,9 +1,10 @@ server { - listen 443 ssl http2; + listen 443 ssl; + http2 on; server_name ${PHPMYADMIN_SERVER_NAME}; ssl_certificate /certs/fullchain.pem; - ssl_certificate_key /certs/privkey.pem; + ssl_certificate_key /certs/private.pem; location / { proxy_pass http://phpmyadmin:80; diff --git a/.docker/php/entrypoint.sh b/.docker/php/entrypoint.sh index e3a37e3b..ff327ddb 100644 --- a/.docker/php/entrypoint.sh +++ b/.docker/php/entrypoint.sh @@ -34,6 +34,8 @@ TARGET_DIR="${ROOT_PATH}/public" ENV_FILE="${ROOT_PATH}/.env" VENDOR_DIR="${ROOT_PATH}/vendor" +chown -R www-data:www-data $ROOT_PATH + if [ "$SERVICE_NAME" = "php" ]; then if [ ! -f "$ENV_FILE" ]; then echo_info ".env file: $ENV_FILE not exists, copy $SOURCE_DIR to $TARGET_DIR ..." diff --git a/docker-compose.yml b/docker-compose.yml index 2356dfe3..a75608be 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,7 +62,7 @@ services: context: ./.docker/openresty container_name: nexusphp-openresty environment: - DOMAIN: ${NP_DOMAIN} + NP_DOMAIN: ${NP_DOMAIN:-localhost} volumes: - ./.docker/openresty/sites:/etc/nginx/conf.d/sites - ./.docker/openresty/certs:/certs