Skip to content

Commit f60c7cb

Browse files
authored
Fix varnish config for arbitrary hostnames (#2573)
1 parent a2f4245 commit f60c7cb

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

config/default.vcl

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
11
# specify the VCL syntax version to use
22
vcl 4.1;
33

4-
# import vmod_dynamic for better backend name resolution
5-
import dynamic;
6-
7-
# we won't use any static backend, but Varnish still need a default one
8-
backend default none;
9-
10-
# set up a dynamic director
11-
# for more info, see https://github.com/nigoroll/libvmod-dynamic/blob/master/src/vmod_dynamic.vcc
12-
sub vcl_init {
13-
new d = dynamic.director(port = "8013");
14-
}
15-
16-
sub vcl_recv {
17-
# force the host header to match the backend (not all backends need it,
18-
# but example.com does)
19-
set req.http.host = "mitxonline.odl.local:8013";
20-
# set the backend
21-
set req.backend_hint = d.backend("mitxonline.odl.local");
4+
backend default {
5+
.host = "nginx";
6+
.port = "8013";
227
}

docker-compose.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ services:
6666
environment:
6767
<< : *py-environment
6868
PORT: 8011
69+
# these are necessary to get the hostname from the varnish proxy
70+
USE_X_FORWARDED_HOST: true
71+
USE_X_FORWARDED_PORT: true
6972
env_file: .env
7073
links:
7174
- db
@@ -86,7 +89,7 @@ services:
8689
ports:
8790
- "8012:8012"
8891
environment:
89-
PUBLIC_PATH: http://${MITX_ONLINE_HOSTNAME:-mitxonline.odl.local}:8012/
92+
PUBLIC_PATH: ${MITX_ONLINE_WATCH_BASE_URL:-http://mitxonline.odl.local:8012/}
9093
NODE_ENV: ${NODE_ENV:-development}
9194
DOCKER_HOST: ${DOCKER_HOST:-missing}
9295
CONTAINER_NAME: 'watch'
@@ -128,7 +131,7 @@ services:
128131
ports:
129132
- "8016:8016"
130133
environment:
131-
PUBLIC_PATH: http://${MITX_ONLINE_HOSTNAME:-mitxonline.odl.local}:8016/
134+
PUBLIC_PATH: ${MITX_ONLINE_REFINE_BASE_URL:-http://mitxonline.odl.local:8016/}
132135
PORT: 8016
133136
NODE_ENV: ${NODE_ENV:-development}
134137
volumes:

0 commit comments

Comments
 (0)