Skip to content

Commit 5178fee

Browse files
authored
Merge pull request #8 from secondlife/signal/name
Add SERVER_NAME option
2 parents 0a1495d + 01f6f94 commit 5178fee

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ Pair nginx-proxy with your favorite upstream server (wsgi, uwsgi, asgi, et al.)
88

99
| Environment Variable | Description | Required | Default | Example |
1010
|----------------------|-------------|----------|---------|---------|
11+
| `LISTEN_PORT` | Server port | Yes | 80 | |
1112
| `PROXY_REVERSE_URL` | Upstream server URL | Yes | | http://myapp:8080 |
12-
| `LISTEN_PORT` | Server port | Yes | 8080 | |
13+
| `SERVER_NAME` | Allowed server names (hostnames) | Yes | | |
1314
| `SILENT` | Silence entrypoint output | No | | |
1415
| `STATIC_LOCATIONS` | Static asset mappings | No | | |
1516

src/etc/nginx/templates/default.conf.template

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
# Default configuration returns 400 in order to deny any request with an
2+
# unrecognized host header (server_name.)
3+
{{ if (ne .Env.SERVER_NAME "_") }}
4+
server {
5+
listen {{ .Env.LISTEN_PORT }};
6+
server_name _;
7+
return 400;
8+
}
9+
{{ end }}
10+
111
server {
212
listen {{ .Env.LISTEN_PORT }};
3-
server_name _;
13+
server_name {{ .Env.SERVER_NAME }};
414
add_header X-Request-ID $request_id;
515

616
# Security Headers

test/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function fail {
99

1010
LISTEN_PORT="8080" \
1111
PROXY_REVERSE_URL="http://localhost:8081" \
12+
SERVER_NAME="localhost" \
1213
STATIC_LOCATIONS="/static/:/test/static/" \
1314
/docker-entrypoint.sh
1415

0 commit comments

Comments
 (0)