Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ RUN wget -O dockerize.tar.gz https://github.com/jwilder/dockerize/releases/downl
# --------------------
# TEMPLATES
# --------------------
COPY default.conf.tpl nginx.conf.tpl /templates/
COPY default.conf.tpl nginx.conf.tpl proxy.conf.tpl /templates/

# --------------------
# FILL TEMPLATES & GO
# --------------------
CMD htpasswd -Bbn "$BASIC_AUTH_USERNAME" "$BASIC_AUTH_PASSWORD" > /etc/nginx/auth.htpasswd && \
dockerize \
-template /templates/default.conf.tpl:/etc/nginx/conf.d/default.conf \
-template /templates/proxy.conf.tpl:/etc/nginx/proxy.conf \
-template /templates/nginx.conf.tpl:/etc/nginx/nginx.conf \
nginx
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Configuration is provided using environment variables:
| `PROXY_BUFFERING` | Enables or disables buffering of responses from the proxied server | `on` |
| `WEBSOCKET_PATH` | Activates websocket handling on the given path | (none) |
| `FORWARD_WEBSOCKET_PATH` | If the remote path differs from `WEBSOCKET_PATH`, use this | (none) |
| `HEALTH_PATH` | For health checks. No authentication required on this path | (none) |


## Usage
Expand Down
20 changes: 8 additions & 12 deletions default.conf.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,20 @@ server {
}
{{ end }}

{{ if .Env.HEALTH_PATH }}
location {{ .Env.HEALTH_PATH }} {
auth_basic "off";
include /etc/nginx/proxy.conf;
}
{{ end }}

location / {

# Basic Auth
limit_except OPTIONS {
auth_basic "Restricted";
auth_basic_user_file "auth.htpasswd";
}

# Proxy
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_pass http://backend;
proxy_read_timeout {{ .Env.PROXY_READ_TIMEOUT }};
proxy_send_timeout {{ .Env.PROXY_SEND_TIMEOUT }};
client_max_body_size {{ .Env.CLIENT_MAX_BODY_SIZE }};
proxy_request_buffering {{ .Env.PROXY_REQUEST_BUFFERING }};
proxy_buffering {{ .Env.PROXY_BUFFERING }};
include /etc/nginx/proxy.conf;
}
}
11 changes: 11 additions & 0 deletions proxy.conf.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Proxy
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_pass http://backend;
proxy_read_timeout {{ .Env.PROXY_READ_TIMEOUT }};
proxy_send_timeout {{ .Env.PROXY_SEND_TIMEOUT }};
client_max_body_size {{ .Env.CLIENT_MAX_BODY_SIZE }};
proxy_request_buffering {{ .Env.PROXY_REQUEST_BUFFERING }};
proxy_buffering {{ .Env.PROXY_BUFFERING }};