Skip to content

Commit 6ec1860

Browse files
authored
Updates
1 parent b0b7293 commit 6ec1860

8 files changed

Lines changed: 100 additions & 37 deletions

File tree

config/etc/nginx/admin/admin.localhost.conf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# You can review the options you set with the console command: es.config
1212

1313
server {
14-
listen 80 deferred fastopen=256 reuseport;
15-
listen [::]:80 deferred fastopen=256 reuseport;
14+
listen 80 deferred fastopen=256 multipath reuseport;
15+
listen [::]:80 deferred fastopen=256 multipath reuseport;
1616
server_name _;
1717
fastcgi_cache off;
1818
set $skip_cache 1;
@@ -21,12 +21,12 @@ server {
2121

2222
server {
2323
# HTTP2
24-
listen 443 default_server ssl deferred fastopen=256 reuseport;
25-
listen [::]:443 default_server ssl deferred fastopen=256 reuseport;
24+
listen 443 default_server ssl deferred fastopen=256 multipath reuseport;
25+
listen [::]:443 default_server ssl deferred fastopen=256 multipath reuseport;
2626

2727
# HTTP3 / QUIC
28-
#listen 443 default_server quic reuseport;
29-
#listen [::]:443 default_server quic reuseport;
28+
#listen 443 default_server multipath quic reuseport;
29+
#listen [::]:443 default_server multipath quic reuseport;
3030

3131
server_name _;
3232

config/etc/nginx/admin/admin.your-domain.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
server {
1010
listen 443 ssl;
1111
listen [::]:443 ssl;
12-
#listen 443 quic reuseport; # HTTP3
13-
#listen [::]:443 quic reuseport; # HTTP3
12+
#listen 443 multipath quic reuseport; # HTTP3
13+
#listen [::]:443 multipath quic reuseport; # HTTP3
1414
server_name admin.YOURDOMAIN;
1515

1616
# SSL Certificates

config/etc/nginx/sites-available/your-domain.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ server {
77
listen [::]:443 ssl;
88

99
# HTTP3 / QUIC
10-
#listen 443 quic reuseport;
11-
#listen [::]:443 quic reuseport;
10+
#listen 443 multipath quic reuseport;
11+
#listen [::]:443 multipath quic reuseport;
1212

1313
server_name YOURDOMAIN www.YOURDOMAIN;
1414

scripts/functions/shared/enginescript-common.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,74 @@ function set_nginx_permissions() {
528528
}
529529

530530

531+
# ----------------------------------------------------------------
532+
# Toggle a commented configuration directive on or off while preserving indentation
533+
function set_commented_directive_state() {
534+
local file_path="$1"
535+
local directive_pattern="$2"
536+
local enable_state="${3:-0}"
537+
538+
if [[ ! -f "${file_path}" ]]; then
539+
return 0
540+
fi
541+
542+
if [[ "${enable_state}" == "1" ]]; then
543+
sed -Ei "s|^([[:space:]]*)#(${directive_pattern})(.*)$|\\1\\2\\3|" "${file_path}"
544+
else
545+
sed -Ei "s|^([[:space:]]*)(${directive_pattern})(.*)$|\\1#\\2\\3|" "${file_path}"
546+
fi
547+
}
548+
549+
550+
# ----------------------------------------------------------------
551+
# Keep Nginx HTTP/3 directives aligned with INSTALL_HTTP3 across all managed configs
552+
function sync_nginx_http3_config() {
553+
local http3_enabled="${INSTALL_HTTP3:-0}"
554+
local quic_gso_enabled=0
555+
local nullglob_was_set=0
556+
local file_path
557+
local site_config_files=()
558+
559+
if [[ "${http3_enabled}" != "1" ]]; then
560+
http3_enabled=0
561+
fi
562+
563+
set_commented_directive_state "/etc/nginx/nginx.conf" "http3 on;" "${http3_enabled}"
564+
set_commented_directive_state "/etc/nginx/nginx.conf" "http3_max_concurrent_streams" "${http3_enabled}"
565+
set_commented_directive_state "/etc/nginx/nginx.conf" "http3_stream_buffer_size" "${http3_enabled}"
566+
set_commented_directive_state "/etc/nginx/nginx.conf" "quic_bpf on;" "${http3_enabled}"
567+
set_commented_directive_state "/etc/nginx/nginx.conf" "quic_retry on;" "${http3_enabled}"
568+
569+
if [[ "${http3_enabled}" == "1" ]] && command -v ethtool >/dev/null 2>&1 && ethtool -k eth0 2>/dev/null | grep -q "tx-gso-robust: on"; then
570+
quic_gso_enabled=1
571+
fi
572+
set_commented_directive_state "/etc/nginx/nginx.conf" "quic_gso on;" "${quic_gso_enabled}"
573+
574+
set_commented_directive_state "/etc/nginx/globals/response-headers.conf" "add_header Alt-Svc" "${http3_enabled}"
575+
set_commented_directive_state "/etc/nginx/globals/response-headers.conf" "add_header x-quic" "${http3_enabled}"
576+
577+
set_commented_directive_state "/etc/nginx/admin/admin.localhost.conf" "listen 443 default_server multipath quic reuseport;" "${http3_enabled}"
578+
set_commented_directive_state "/etc/nginx/admin/admin.localhost.conf" "listen \[::\]:443 default_server multipath quic reuseport;" "${http3_enabled}"
579+
580+
if shopt -q nullglob; then
581+
nullglob_was_set=1
582+
else
583+
shopt -s nullglob
584+
fi
585+
586+
site_config_files=(/etc/nginx/sites-available/your-domain.conf /etc/nginx/sites-enabled/*.conf /etc/nginx/admin/admin.*.conf)
587+
588+
if [[ "${nullglob_was_set}" == "0" ]]; then
589+
shopt -u nullglob
590+
fi
591+
592+
for file_path in "${site_config_files[@]}"; do
593+
set_commented_directive_state "${file_path}" "listen 443 multipath quic reuseport;" "${http3_enabled}"
594+
set_commented_directive_state "${file_path}" "listen \[::\]:443 multipath quic reuseport;" "${http3_enabled}"
595+
done
596+
}
597+
598+
531599
# ----------------------------------------------------------------
532600
# Set permissions for PHP directories and files
533601
function set_php_permissions() {

scripts/functions/shared/enginescript-shared-vhost.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,8 @@ create_nginx_vhost() {
9898
echo ""
9999
fi
100100

101-
# Enable HTTP/3 if configured
102-
if [[ "${INSTALL_HTTP3}" == "1" ]]; then
103-
sed -i "s|#listen 443 quic|listen 443 quic|g" "/etc/nginx/sites-enabled/${DOMAIN}.conf"
104-
sed -i "s|#listen [::]:443 quic|listen [::]:443 quic|g" "/etc/nginx/sites-enabled/${DOMAIN}.conf"
105-
fi
101+
# Keep template-derived HTTP/3 listeners aligned with the current setting.
102+
sync_nginx_http3_config
106103
}
107104

108105

scripts/install/nginx/nginx-tune.sh

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,8 @@ if [[ "${NGINX_HASH_BUCKET}" = 128 ]];
9393
sed -i "s|SEDHASHMAXSIZE|2048|g" /etc/nginx/nginx.conf
9494
fi
9595

96-
# HTTP3
97-
if [[ "${INSTALL_HTTP3}" = 1 ]]; then
98-
sed -i "s|#http3 on;|http3 on;|g" /etc/nginx/nginx.conf
99-
sed -i "s|#http3_max_concurrent_streams|http3_max_concurrent_streams|g" /etc/nginx/nginx.conf
100-
sed -i "s|#http3_stream_buffer_size|http3_stream_buffer_size|g" /etc/nginx/nginx.conf
101-
sed -i "s|#quic_bpf on|quic_bpf on|g" /etc/nginx/nginx.conf
102-
sed -i "s|#quic_retry on|quic_retry on|g" /etc/nginx/nginx.conf
103-
sed -i "s|#add_header Alt-Svc|add_header Alt-Svc|g" /etc/nginx/globals/response-headers.conf
104-
sed -i "s|#add_header x-quic|add_header x-quic|g" /etc/nginx/globals/response-headers.conf
105-
sed -i "s|#listen 443 quic|listen 443 quic|g" "/etc/nginx/admin/admin.localhost.conf"
106-
sed -i "s|#listen [::]:443 quic|listen [::]:443 quic|g" "/etc/nginx/admin/admin.localhost.conf"
107-
fi
108-
109-
# HTTP3 - QUIC GSO (requires hardware support check)
110-
if [[ "${INSTALL_HTTP3}" = 1 ]] && ethtool -k eth0 | grep "tx-gso-robust: on"; then
111-
sed -i "s|#quic_gso on|quic_gso on|g" /etc/nginx/nginx.conf
112-
fi
113-
96+
# Keep HTTP/3 directives aligned with INSTALL_HTTP3 across core and vhost configs.
97+
sync_nginx_http3_config
11498

11599
# References:
116100
# https://www.cloudbees.com/blog/tuning-nginx

scripts/install/tools/frontend/admin-control-panel-install.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,20 @@ cp -a /usr/local/bin/enginescript/config/var/www/admin/control-panel/. /var/www/
3232
# inline JS comments/strings in index.html, so we scope the substitution to only
3333
# the specific Font Awesome CDN URL that contains the version segment. If the
3434
# Font Awesome CDN path changes, update the pattern below accordingly.
35-
sed -i "s|https://cdnjs.cloudflare.com/ajax/libs/font-awesome/{FONTAWESOME_VER}/css/all.min.css|https://cdnjs.cloudflare.com/ajax/libs/font-awesome/${FONTAWESOME_VER}/css/all.min.css|g" /var/www/admin/control-panel/index.html
36-
# Verify that the Font Awesome placeholder was successfully replaced to avoid silent failures
37-
if grep -q '{FONTAWESOME_VER}' /var/www/admin/control-panel/index.html; then
38-
echo "Error: Failed to substitute Font Awesome version in index.html; placeholder {FONTAWESOME_VER} still present." >&2
35+
CONTROL_PANEL_INDEX="/var/www/admin/control-panel/index.html"
36+
FONTAWESOME_CDN_PLACEHOLDER='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/{FONTAWESOME_VER}/css/all.min.css'
37+
FONTAWESOME_CDN_URL="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/${FONTAWESOME_VER}/css/all.min.css"
38+
39+
sed -i "s|${FONTAWESOME_CDN_PLACEHOLDER}|${FONTAWESOME_CDN_URL}|g" "$CONTROL_PANEL_INDEX"
40+
41+
# Verify the CDN URL was replaced without treating explanatory comments/strings as failures.
42+
if grep -Fq "$FONTAWESOME_CDN_PLACEHOLDER" "$CONTROL_PANEL_INDEX"; then
43+
echo "Error: Failed to substitute Font Awesome version in index.html CDN URL; placeholder path still present." >&2
44+
exit 1
45+
fi
46+
47+
if ! grep -Fq "$FONTAWESOME_CDN_URL" "$CONTROL_PANEL_INDEX"; then
48+
echo "Error: Failed to configure Font Awesome CDN URL in index.html." >&2
3949
exit 1
4050
fi
4151

scripts/update/nginx-update.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ debug_pause "Misc Nginx Stuff"
7272

7373
# Tune Nginx
7474
/usr/local/bin/enginescript/scripts/install/nginx/nginx-tune.sh 2>> /tmp/enginescript_install_errors.log
75+
76+
# Re-sync HTTP/3 directives after rebuild so existing vhosts match INSTALL_HTTP3.
77+
sync_nginx_http3_config 2>> /tmp/enginescript_install_errors.log
78+
7579
print_last_errors
7680
debug_pause "Tune Nginx"
7781

0 commit comments

Comments
 (0)