Skip to content

Commit fb30b57

Browse files
committed
Update docker-entrypoint scripts
1 parent 2638913 commit fb30b57

File tree

2 files changed

+62
-16
lines changed

2 files changed

+62
-16
lines changed

Dockerfiles/data/docker-entrypoint.d/.httpd/func-backend.sh

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ set -o pipefail
2222
### conf:phpfpm:tcp:<host>:<port> # Remote PHP-FPM server at <host>:<port>
2323
### conf:rproxy:http:<host>:<port> # Reverse Proxy server at http://<host>:<port>
2424
### conf:rproxy:https:<host>:<port> # Reverse Proxy server at https://<host>:<port>
25+
### conf:rproxy:ws:<host>:<port> # Reverse Proxy (websocket) at ws://<host>:<port>
26+
### conf:rproxy:wss:<host>:<port> # Reverse Proxy (websocket) at wss://<host>:<port>
2527
###
2628
###
2729
### Format-2: file:<file>
@@ -40,6 +42,8 @@ set -o pipefail
4042
### Examples:
4143
### conf:rproxy:http:10.0.0.1:3000
4244
### conf:rproxy:https:mydomain.com:8080
45+
### conf:rproxy:ws:10.0.0.1:3000
46+
### conf:rproxy:wss:10.0.0.1:3000
4347
###
4448
### Note: If no file is found, a warning will be logged and no Reverse proxy will be created.
4549
###
@@ -90,7 +94,13 @@ backend_conf_is_valid() {
9094
fi
9195
# 3. Protocol: 'tcp', 'http' or 'https'
9296
if ! backend_is_valid_conf_prot "${1}"; then
93-
echo "Invalid backend conf:<prot> in: '${1}'. It must be 'tcp', 'http' or 'https'"
97+
# Apache 2.2 does not have websocket support
98+
if [ "${VHOSTGEN_HTTPD_SERVER}" = "apache22" ]; then
99+
echo "Invalid backend conf:<prot> in: '${1}'. It must be 'tcp', 'http' or 'https'."
100+
# All other webserver have websocket support
101+
else
102+
echo "Invalid backend conf:<prot> in: '${1}'. It must be 'tcp', 'http', 'https', 'ws' or 'wss'."
103+
fi
94104
return 1
95105
fi
96106
# 4. Host
@@ -116,9 +126,22 @@ backend_conf_is_valid() {
116126
fi
117127
# 7. Validate conf <protocol> rproxy == http(s)?
118128
if [ "${backend_conf_type}" = "rproxy" ]; then
119-
if [ "${backend_conf_prot}" != "http" ] && [ "${backend_conf_prot}" != "https" ]; then
120-
echo "Invalid backend conf:<prot> in: '${1}'. 'rproxy' only supports 'http' or 'https'"
121-
return 1
129+
# Apache 2.2 does not have websocket support
130+
if [ "${VHOSTGEN_HTTPD_SERVER}" = "apache22" ]; then
131+
if [ "${backend_conf_prot}" != "http" ] \
132+
&& [ "${backend_conf_prot}" != "https" ]; then
133+
echo "Invalid backend conf:<prot> in: '${1}'. 'rproxy' only supports 'http' and 'https'"
134+
return 1
135+
fi
136+
# All other webserver have websocket support
137+
else
138+
if [ "${backend_conf_prot}" != "http" ] \
139+
&& [ "${backend_conf_prot}" != "https" ] \
140+
&& [ "${backend_conf_prot}" != "ws" ] \
141+
&& [ "${backend_conf_prot}" != "wss" ]; then
142+
echo "Invalid backend conf:<prot> in: '${1}'. 'rproxy' only supports 'http', 'https', 'ws' and 'wss'"
143+
return 1
144+
fi
122145
fi
123146
fi
124147
}
@@ -181,8 +204,14 @@ backend_is_valid_conf_prot() {
181204
local value
182205
value="$( get_backend_conf_prot "${1}" )"
183206

184-
if [ "${value}" != "tcp" ] && [ "${value}" != "http" ] && [ "${value}" != "https" ]; then
185-
return 1
207+
if [ "${VHOSTGEN_HTTPD_SERVER}" = "apache22" ];then
208+
if [ "${value}" != "tcp" ] && [ "${value}" != "http" ] && [ "${value}" != "https" ]; then
209+
return 1
210+
fi
211+
else
212+
if [ "${value}" != "tcp" ] && [ "${value}" != "http" ] && [ "${value}" != "https" ] && [ "${value}" != "ws" ] && [ "${value}" != "wss" ]; then
213+
return 1
214+
fi
186215
fi
187216
return 0
188217
}

Dockerfiles/data/docker-entrypoint.d/02-env-vars-validate.sh

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,12 @@ _validate_vhost_backend() {
647647
# 5. Validate conf <protocol>
648648
if ! backend_is_valid_conf_prot "${value}"; then
649649
_log_env_valid "invalid" "${name}" "${value}" "Invalid format"
650-
_log_env_valid "invalid" "${name}" "${backend_conf_prot}" "<proto> is invalid. Must be: " "'tcp', 'http' or 'https'"
650+
# Apache 2.2 does not have websocket support
651+
if [ "${VHOSTGEN_HTTPD_SERVER}" = "apache22" ];then
652+
_log_env_valid "invalid" "${name}" "${backend_conf_prot}" "<proto> is invalid. Must be: " "'tcp', 'http' or 'https'"
653+
else
654+
_log_env_valid "invalid" "${name}" "${backend_conf_prot}" "<proto> is invalid. Must be: " "'tcp', 'http', 'https', 'ws' or 'wss'"
655+
fi
651656
_log_backend_examples "conf"
652657
exit 1
653658
fi
@@ -662,11 +667,21 @@ _validate_vhost_backend() {
662667
fi
663668
# 7. Validate conf <protocol> rproxy == http(s)?
664669
if [ "${backend_conf_type}" = "rproxy" ]; then
665-
if [ "${backend_conf_prot}" != "http" ] && [ "${backend_conf_prot}" != "https" ]; then
666-
_log_env_valid "invalid" "${name}" "${value}" "Invalid format"
667-
_log_env_valid "invalid" "${name}" "${backend_conf_prot}" "rproxy only supports protocol " "'http' or 'https'"
668-
_log_backend_examples "conf"
669-
exit 1
670+
# Apache 2.2 does not have websocket support
671+
if [ "${VHOSTGEN_HTTPD_SERVER}" = "apache22" ];then
672+
if [ "${backend_conf_prot}" != "http" ] && [ "${backend_conf_prot}" != "https" ]; then
673+
_log_env_valid "invalid" "${name}" "${value}" "Invalid format"
674+
_log_env_valid "invalid" "${name}" "${backend_conf_prot}" "rproxy only supports protocol " "'http' and 'https'"
675+
_log_backend_examples "conf"
676+
exit 1
677+
fi
678+
else
679+
if [ "${backend_conf_prot}" != "http" ] && [ "${backend_conf_prot}" != "https" ] && [ "${backend_conf_prot}" != "ws" ] && [ "${backend_conf_prot}" != "wss" ]; then
680+
_log_env_valid "invalid" "${name}" "${value}" "Invalid format"
681+
_log_env_valid "invalid" "${name}" "${backend_conf_prot}" "rproxy only supports protocol " "'http', 'https', 'ws' and 'wss'"
682+
_log_backend_examples "conf"
683+
exit 1
684+
fi
670685
fi
671686
fi
672687
# 8. Validate conf <host>
@@ -1062,11 +1077,13 @@ _log_backend_examples() {
10621077
log "err" "Example: conf:phpfpm:tcp:10.0.0.100:9000"
10631078
log "err" "Example: conf:phpfpm:tcp:domain.com:9000"
10641079
log "err" ""
1065-
log "err" "Example: conf:rproxy:http:10.0.0.100:3000"
1066-
log "err" "Example: conf:rproxy:http:domain.com:443"
1067-
log "err" ""
1068-
log "err" "Example: conf:rproxy:https:10.0.0.100:8080"
1080+
log "err" "Example: conf:rproxy:http:10.0.0.100:8080"
10691081
log "err" "Example: conf:rproxy:https:domain.com:8443"
1082+
if [ "${VHOSTGEN_HTTPD_SERVER}" != "apache22" ]; then
1083+
log "err" ""
1084+
log "err" "Example: conf:rproxy:ws:10.0.0.100:8080"
1085+
log "err" "Example: conf:rproxy:wss:domain.com:8443"
1086+
fi
10701087
fi
10711088
if [ "${show}" = "all" ] || [ "${show}" = "file" ]; then
10721089
log "err" ""

0 commit comments

Comments
 (0)