Skip to content

Commit

Permalink
First step in debugging proxy trust issue
Browse files Browse the repository at this point in the history
  • Loading branch information
naxxfish committed Apr 30, 2018
1 parent 8a6238c commit 1bc0293
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ app.set( 'views', __views );
app.set( 'view engine', 'pug' );
app.set( 'view cache', false );

// Set reverse proxy trust (see http://expressjs.com/en/guide/behind-proxies.html)
// default to false
app.set( 'trust proxy', config.reverseProxyTrust || false )

// Load apps
app_loader( app );

Expand Down
3 changes: 2 additions & 1 deletion config/example-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
"iterations": 50000,
"dev": true,
"log": "/var/log/membership.log",
"logStdout": false
"logStdout": false,
"reverseProxyTrust":"loopback"
}
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ services:
image: ministryofjustice/mailcatcher
ports:
- "1080:1080"
proxy:
image: nginx
build: ./nginx/
ports:
- "8080:8080"
2 changes: 2 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM nginx
COPY membership.conf /etc/nginx/conf.d/membership.conf
11 changes: 11 additions & 0 deletions nginx/membership.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
server {
server_name localhost;
listen 8080;
location / {
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://membership:3001;
}
}
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ Stub out your app structure within `app/`, this will include:


Check out these files to get an idea of how each of these should be structure.

## Reverse proxy
If running behind a reverse proxy, you should configure your proxy to add the `X-Forwarded-*` headers (see [nginx documentation](https://www.nginx.com/resources/wiki/start/topics/examples/forwarded/)), and also set reverseProxyTrust variable in `config/config.json`

0 comments on commit 1bc0293

Please sign in to comment.