Skip to content

Commit

Permalink
Add LISTEN_PORT_80 environment variable to bind apache2 to port 80 fo…
Browse files Browse the repository at this point in the history
…r any user
  • Loading branch information
Toilal committed Oct 9, 2018
1 parent 61565cb commit 660a055
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ to tune it:
* MS_ERRORFILE: If you want the debug to something other than STDOUT
* MAX_REQUESTS_PER_PROCESS: To work around memory leaks (defaults to 1000)
* MAPSERVER_CATCH_SEGV: Set to 1 to have the stacktraces in case of crash
* LISTEN_PORT_80: When running the container as an unprivileged user, apache
will listen to port 8080 instead of 80. Set to 1 force listening to port 80
instead.

## Project version

Expand Down
5 changes: 5 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ RUN apt-get update && \
chmod a+rx /bin/confd && \
mkdir --parent /etc/confd/conf.d /etc/confd/templates /etc/mapserver /docker-entrypoint.d

# Allow apache2 to bind to port <1024 for any user
RUN apt-get update && apt-get install -y libcap2-bin && setcap cap_net_bind_service=+ep /usr/sbin/apache2 && \
rm -rf /var/lib/apt/lists/* &&\
apt-get purge -y libcap2-bin

EXPOSE 80

COPY runtime /
Expand Down
2 changes: 1 addition & 1 deletion server/runtime/usr/local/bin/start-server
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
# Save the environment to be able to restore it in the FCGI daemon (used in /usr/local/bin/mapserv_wrapper)
env | sed -e 's/.\+/export "\0"/' > /tmp/init_env

if [[ "${UID}" != 0 ]]
if [ "${UID}" != 0 ] && [ "${LISTEN_PORT_80}" != 1 ]
then
echo "Switching listen port to 8080"
cd /tmp
Expand Down

0 comments on commit 660a055

Please sign in to comment.