Skip to content

Commit

Permalink
[Fixes #9041] Docker NGINX listen on ports 80/443 (#10338) (#10340) (#…
Browse files Browse the repository at this point in the history
…10343)

Co-authored-by: Francesco Frassinelli <francesco.frassinelli@nina.no>

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Francesco Frassinelli <francesco.frassinelli@nina.no>
  • Loading branch information
github-actions[bot] and frafra authored Nov 23, 2022
1 parent 5cd25d7 commit f0c3b7c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
12 changes: 3 additions & 9 deletions scripts/docker/nginx/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,14 @@ else
fi

echo "Sanity checks on http/s ports configuration"
if [ -z "${HTTP_PORT}" ]; then
HTTP_PORT=80
fi
if [ -z "${HTTPS_PORT}" ]; then
HTTPS_PORT=443
fi
if [ -z "${JENKINS_HTTP_PORT}" ]; then
JENKINS_HTTP_PORT=9080
fi

echo "Replacing environement variables"
envsubst '\$HTTP_PORT \$HTTPS_PORT \$HTTP_HOST \$HTTPS_HOST \$RESOLVER' < /etc/nginx/nginx.conf.envsubst > /etc/nginx/nginx.conf
envsubst '\$HTTP_PORT \$HTTPS_PORT \$HTTP_HOST \$HTTPS_HOST \$RESOLVER' < /etc/nginx/nginx.https.available.conf.envsubst > /etc/nginx/nginx.https.available.conf
envsubst '\$HTTP_PORT \$HTTPS_PORT \$HTTP_HOST \$HTTPS_HOST \$JENKINS_HTTP_PORT' < /etc/nginx/sites-enabled/geonode.conf.envsubst > /etc/nginx/sites-enabled/geonode.conf
envsubst '\$HTTP_HOST \$HTTPS_HOST \$RESOLVER' < /etc/nginx/nginx.conf.envsubst > /etc/nginx/nginx.conf
envsubst '\$HTTP_HOST \$HTTPS_HOST \$RESOLVER' < /etc/nginx/nginx.https.available.conf.envsubst > /etc/nginx/nginx.https.available.conf
envsubst '\$HTTP_HOST \$HTTPS_HOST \$JENKINS_HTTP_PORT' < /etc/nginx/sites-enabled/geonode.conf.envsubst > /etc/nginx/sites-enabled/geonode.conf

echo "Enabling or not https configuration"
if [ -z "${HTTPS_HOST}" ]; then
Expand Down
6 changes: 3 additions & 3 deletions scripts/docker/nginx/nginx.conf.envsubst
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ http {
# even if not used (HTTP_HOST empty), we must keep it as it's used for internal API calls between django and geoserver
# TODO : do not use unencrypted connection even on LAN, but is it possible to have browser not complaining about unknown authority ?
server {
listen $HTTP_PORT;
listen 80;
server_name $HTTP_HOST 127.0.0.1 geonode;

include sites-enabled/*.conf;
}

# Default server closes the connection (we can connect only using HTTP_HOST and HTTPS_HOST)
server {
listen $HTTP_PORT default_server;
listen $HTTPS_PORT;
listen 80 default_server;
listen 443;
server_name _;
return 444;
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/nginx/nginx.https.available.conf.envsubst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ssl_session_timeout 10m;

# this is the actual HTTPS host
server {
listen $HTTPS_PORT ssl;
listen 443 ssl;
server_name $HTTPS_HOST;
keepalive_timeout 70;

Expand Down

0 comments on commit f0c3b7c

Please sign in to comment.