2022-03-17 13:10:51 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2022-06-01 05:44:27 +00:00
|
|
|
set -o errexit
|
|
|
|
|
set -o pipefail
|
|
|
|
|
set -o nounset
|
2022-06-15 08:31:46 +00:00
|
|
|
set -o noglob
|
2022-06-01 05:44:27 +00:00
|
|
|
|
2022-06-15 08:31:46 +00:00
|
|
|
declare -a proxy_args
|
|
|
|
|
proxy_configured=0
|
2022-06-01 05:44:27 +00:00
|
|
|
|
2023-02-24 09:23:08 +00:00
|
|
|
match-proxy-url() {
|
|
|
|
|
# Examples:
|
|
|
|
|
# http://proxy.example.com:8080/
|
|
|
|
|
# http://user:pass@proxyhost:123
|
|
|
|
|
# http://proxyhost:123
|
|
|
|
|
[[ $1 =~ ^http://(([^@:]*):([^@]*)?@)?([^@:]*):([0-9]+)/?$ ]]
|
|
|
|
|
proxy_user="${BASH_REMATCH[2]-}"
|
|
|
|
|
proxy_pass="${BASH_REMATCH[3]-}"
|
|
|
|
|
proxy_host="${BASH_REMATCH[4]-}"
|
|
|
|
|
proxy_port="${BASH_REMATCH[5]-}"
|
|
|
|
|
[[ -n $proxy_host ]]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if match-proxy-url "${HTTP_PROXY-}"; then
|
|
|
|
|
proxy_args+=(-Dhttp.proxyHost="$proxy_host" -Dhttp.proxyPort="$proxy_port")
|
|
|
|
|
if [[ -n $proxy_user ]]; then
|
|
|
|
|
proxy_args+=(-Dhttp.proxyUser="$proxy_user")
|
|
|
|
|
fi
|
|
|
|
|
if [[ -n $proxy_pass ]]; then
|
|
|
|
|
proxy_args+=(-Dhttp.proxyPassword="$proxy_pass")
|
|
|
|
|
fi
|
2022-06-15 08:31:46 +00:00
|
|
|
proxy_configured=1
|
2022-06-01 05:44:27 +00:00
|
|
|
fi
|
|
|
|
|
|
2023-02-24 09:23:08 +00:00
|
|
|
if match-proxy-url "${HTTPS_PROXY-}"; then
|
|
|
|
|
proxy_args+=(-Dhttps.proxyHost="$proxy_host" -Dhttps.proxyPort="$proxy_port")
|
|
|
|
|
if [[ -n $proxy_user ]]; then
|
|
|
|
|
proxy_args+=(-Dhttps.proxyUser="$proxy_user")
|
|
|
|
|
fi
|
|
|
|
|
if [[ -n $proxy_pass ]]; then
|
|
|
|
|
proxy_args+=(-Dhttps.proxyPassword="$proxy_pass")
|
|
|
|
|
fi
|
2022-06-15 08:31:46 +00:00
|
|
|
proxy_configured=1
|
2022-06-01 05:44:27 +00:00
|
|
|
fi
|
|
|
|
|
|
2022-07-25 02:12:48 +00:00
|
|
|
if [[ -z "${NO_PROXY-}" ]]; then
|
2022-06-01 05:44:27 +00:00
|
|
|
# A default for this value is set in entrypoint.sh script.
|
2022-07-25 02:12:48 +00:00
|
|
|
# If this variable is not set, just set it to empty string.
|
2022-06-01 05:44:27 +00:00
|
|
|
NO_PROXY=""
|
|
|
|
|
fi
|
|
|
|
|
|
2022-06-15 08:31:46 +00:00
|
|
|
if [[ $proxy_configured == 1 ]]; then
|
fix: NO_PROXY not set correctly on backend server (#20605)
When we have `NO_PROXY=localhost,one.com,two.com,three.com`, then the
current implementation will pass the following to the backend server:
```
localhost|one.com,two.com,three.com
```
This will mean that only `localhost` will bypass the proxy, which is not
what's expected.
This PR fixes this problem, so that the following is sent to the backend
server:
```
localhost|one.com|two.com|three.com
```
This will mean that requests to all four of them, will bypass the proxy,
as expected.
2023-02-14 13:43:19 +00:00
|
|
|
proxy_args+=(-Djava.net.useSystemProxies=true -Dhttp.nonProxyHosts="${NO_PROXY//,/|}")
|
2022-06-15 08:31:46 +00:00
|
|
|
fi
|
|
|
|
|
|
2023-01-02 09:55:23 +00:00
|
|
|
# Wait until RTS started and listens on port 8091
|
|
|
|
|
while ! curl --fail --silent localhost/rts-api/v1/health-check; do
|
|
|
|
|
echo 'Waiting for RTS to start ...'
|
|
|
|
|
sleep 1
|
|
|
|
|
done
|
|
|
|
|
echo 'RTS started.'
|
|
|
|
|
|
2023-06-06 13:02:40 +00:00
|
|
|
sh /opt/appsmith/run-starting-page-init.sh &
|
2023-01-02 09:55:23 +00:00
|
|
|
|
2022-03-17 13:10:51 +00:00
|
|
|
# Ref -Dlog4j2.formatMsgNoLookups=true https://spring.io/blog/2021/12/10/log4j2-vulnerability-and-spring-boot
|
2022-06-01 05:44:27 +00:00
|
|
|
exec java ${APPSMITH_JAVA_ARGS:-} ${APPSMITH_JAVA_HEAP_ARG:-} \
|
2023-01-02 12:40:59 +00:00
|
|
|
--add-opens java.base/java.time=ALL-UNNAMED \
|
2022-06-01 05:44:27 +00:00
|
|
|
-Dserver.port=8080 \
|
2023-08-30 11:22:48 +00:00
|
|
|
-XX:+ShowCodeDetailsInExceptionMessages \
|
2022-06-01 05:44:27 +00:00
|
|
|
-Djava.security.egd=file:/dev/./urandom \
|
|
|
|
|
-Dlog4j2.formatMsgNoLookups=true \
|
2022-06-15 08:31:46 +00:00
|
|
|
"${proxy_args[@]}" \
|
2022-06-01 05:44:27 +00:00
|
|
|
-jar server.jar
|