Skip to content

Commit 243eb86

Browse files
jaapmarcusasmcc
andauthored
HESTIA-NGINX: Automatic listing on IPV4 or/and IPV6 address (hestiacp#3593)
Co-authored-by: asmcc <root@test.hestiacp.com>
1 parent 1eee22c commit 243eb86

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/deb/nginx/hestia

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ NGINX_DAEMON=/usr/local/hestia/nginx/sbin/hestia-nginx
1717
NGINX_NAME=hestia-nginx
1818
NGINX_DESC=hestia-nginx
1919
NGINX_PID=/run/hestia-nginx.pid
20+
NGINX_CONF=/usr/local/hestia/nginx/conf/nginx.conf
2021

2122
PHP_DAEMON=/usr/local/hestia/php/sbin/hestia-php
2223
PHP_NAME=hestia-php
@@ -30,7 +31,23 @@ set -e
3031

3132
. /etc/profile.d/hestia.sh
3233

34+
adapt_nginx_config() {
35+
ipv4_string="$(ip -4 addr show scope global | sed -ne '/^[ \t]*inet[6]*/p')"
36+
ipv6_string="$(ip -6 addr show scope global | sed -ne '/^[ \t]*inet[6]*/p')"
37+
if [ -n "$ipv4_string" ]; then
38+
sed -i 's/#IPV4\([ \t]*listen[ \t]*[0-9]\{1,5\}.*\)/\1/' ${NGINX_CONF}
39+
else
40+
sed -i 's/^\([ \t]*listen[ \t]*[0-9]\{1,5\}.*\)/#IPV4\1/' ${NGINX_CONF}
41+
fi
42+
if [ -n "$ipv6_string" ]; then
43+
sed -i 's/#IPV6\([ \t]*listen[ \t]*\[\:\:\]\:[0-9]\{1,5\}.*\)/\1/' ${NGINX_CONF}
44+
else
45+
sed -i 's/^\([ \t]*listen[ \t]*\[\:\:\]\:[0-9]\{1,5\}.*\)/#IPV6\1/' ${NGINX_CONF}
46+
fi
47+
}
48+
3349
start_nginx() {
50+
adapt_nginx_config
3451
start-stop-daemon --start --quiet --pidfile $NGINX_PID \
3552
--retry 5 --exec $NGINX_DAEMON --oknodo
3653
}

src/deb/nginx/nginx.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ http {
9292

9393
# Vhost
9494
server {
95-
listen 8083 ssl;
95+
#IPV4 listen 8083 ssl;
96+
#IPV6 listen [::]:8083 ssl;
9697
server_name _;
9798
root /usr/local/hestia/web;
9899
# Fix error "The plain HTTP request was sent to HTTPS port"

0 commit comments

Comments
 (0)