Sign inSign up

mrnehu/reverse-proxy

By mrnehu

Updated about 6 years ago

A simple, easy-to-configure reverse proxy with optional basic authentication support.

Image
0

342

mrnehu/reverse-proxy repository overview

reverse-proxy image

A simple, easy-to-configure reverse proxy with optional basic authentication support.

docker pull mrnehu/reverse-proxy

This image builds upon Nginx.

Usage

This image is configured through environment variables:

  • server_name: (mandatory) A name for the server
  • Locations: each location defines a redirection from the public endpoint to a backend server; define any number of locations by using an numeric index n starting with 0.
    • locationn_source: (mandatory) The public endpoint
    • locationn_destination: (mandatory) The backend server
    • locationn_basicauth: (optional, default: 0) Enable basic authentication (1) or not (0) on this endpoint.
    • locationn_setbaseurl: (optional, default: 0) Force setting the base URL in HTML responses from the upstream server (1) or not (0) on this endpoint.
      • This is useful when the source and destination do not share the same context, and the upstream application does not allow configuring the listening endpoint.
    • locationn_returncode: (optional) If set, the destination locationn_destination will be ignored and requests will be answered by the reverse-proxy with the indicated HTTP return code (200 for regular responses).
    • locationn_returnbody: (optional) If locationn_returncode is set, then the locationn_returnbody defines the body of the response; it may also be left empty.
  • Users: the .htpasswd entries; define any number of entries by using an numeric index n starting with 0. See "Basic authentication" for more information.
    • usern: (mandatory) The .htpasswd user entry

The image generates its configuration based on the environment variables. Alternatively, it is possible to mount an own nginx.conf file to /etc/nginx/nginx.conf. The container will detect this and will not change the mounted file.

See docker-compose.yml for a usage example.

Basic authentication

Basic authentication requires the generation of an .htpasswd file. This can be done with the apache tools (usually available as a separate package).

Generate the .htpasswd file as follows:

htpasswd -B -c .htpasswd username

The -B flag forces the bcrypt algorithm, which is more secure than the default md5 algorithm.

The -c flag indicates that a new file is created (omit to append additional users).

Print out the contents in the docker-compose.yml format, and insert them under the environment section:

cat .htpasswd | sed 's|$|$$|g' | awk "{print \"user\" NR-1 \": '\" \$0 \"'\"}"

The .htpasswd file is no longer needed and can be deleted.

Tag summary

Content type

Image

Digest

Size

9.7 MB

Last updated

about 6 years ago

docker pull mrnehu/reverse-proxy