Skip to content

Commit

Permalink
#110 Nginx 1.25.1 이상 버전의 http2 on 설정 분기 지원
Browse files Browse the repository at this point in the history
  • Loading branch information
ibin79 committed Nov 17, 2024
1 parent 88bc481 commit 699e18e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
13 changes: 13 additions & 0 deletions letsencrypt/template-server-1.25.1.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#listen 443 ssl http2; # nginx 1.25.1 이전 버전 (1.24.0 등)
listen 443 ssl; # nginx 1.25.1 이상 버전
http2 on; # nginx 1.25.1 이상 버전 https://github.com/php79/stack/issues/110

ssl_certificate /etc/letsencrypt/live/_INPUT_DOMAIN_/fullchain.pem;
ssl_trusted_certificate /etc/letsencrypt/live/_INPUT_DOMAIN_/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/_INPUT_DOMAIN_/privkey.pem;
include /etc/letsencrypt/php79/ssl-stable.conf;

# Force https
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
5 changes: 4 additions & 1 deletion letsencrypt/template-server.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
listen 443 ssl http2;
listen 443 ssl http2; # nginx 1.25.1 이전 버전 (1.24.0 등)
#listen 443 ssl; # nginx 1.25.1 이상 버전
#http2 on; # nginx 1.25.1 이상 버전 https://github.com/php79/stack/issues/110

ssl_certificate /etc/letsencrypt/live/_INPUT_DOMAIN_/fullchain.pem;
ssl_trusted_certificate /etc/letsencrypt/live/_INPUT_DOMAIN_/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/_INPUT_DOMAIN_/privkey.pem;
Expand Down
16 changes: 14 additions & 2 deletions ssl-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,20 @@ if [ ${INPUT_SKIP_NGINX} != "1" ]; then
if [ "${?}" != "1" ]; then
outputComment "# nginx 에 'listen ... ssl' 설정이 이미 추가되었으므로 생략합니다.\n"
else
# Nginx 1.25.1 이상 http2 on 설정 분리
NGINX_VERSION_CURRENT=$(/usr/sbin/nginx -v 2>&1 | grep -o '[0-9.]\+')
NGINX_VERSION_REQUIRED="1.25.1"
NGINX_VERSION_SORT_FIRST=$(printf '%s\n' ${NGINX_VERSION_REQUIRED} ${NGINX_VERSION_CURRENT} | sort -V | head -n1)

if [ ${NGINX_VERSION_SORT_FIRST} = ${NGINX_VERSION_REQUIRED} ]; then
# 1.25.1 이상
LETSENCRYPT_TEMPLATE="template-server-1.25.1.conf"
else
LETSENCRYPT_TEMPLATE="template-server.conf"
fi

outputComment "# nginx 설정의 마지막에 다음 설정을 추가합니다.\n\n"
sed -e "s/_INPUT_DOMAIN_/${INPUT_DOMAIN}/g" "${STACK_ROOT}/letsencrypt/template-server.conf"
sed -e "s/_INPUT_DOMAIN_/${INPUT_DOMAIN}/g" "${STACK_ROOT}/letsencrypt/${LETSENCRYPT_TEMPLATE}"
echo

# 마지막 } 문자를 #} 로 주석 처리
Expand All @@ -243,7 +255,7 @@ if [ ${INPUT_SKIP_NGINX} != "1" ]; then
rm -f /tmp/php79-ssl-install-nginx

# 마지막에 SSL 설정 추가
sed -e "s/_INPUT_DOMAIN_/${INPUT_DOMAIN}/g" "${STACK_ROOT}/letsencrypt/template-server.conf" >> ${NGINX_USER_CONF}
sed -e "s/_INPUT_DOMAIN_/${INPUT_DOMAIN}/g" "${STACK_ROOT}/letsencrypt/${LETSENCRYPT_TEMPLATE}" >> ${NGINX_USER_CONF}
echo "}" >> ${NGINX_USER_CONF}

outputComment "# nginx 설정 변경후, nginx 설정을 다시 테스트합니다.\n"
Expand Down

0 comments on commit 699e18e

Please sign in to comment.