Skip to content

Commit

Permalink
feat: express trusts proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
pbastia committed Sep 21, 2021
1 parent b4a62a2 commit 4c70bea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 2 additions & 8 deletions app/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ const getRedirectURL = (req) => {
app.prepare().then(async () => {
const server = express();

server.set('trust proxy', true);

const lightship = createLightship();

lightship.registerShutdownHandler(async () => {
Expand All @@ -114,14 +116,6 @@ app.prepare().then(async () => {

server.use(redirectRouter);

// Enable serving ACME HTTP-01 challenge response written to disk by acme.sh
// https://letsencrypt.org/docs/challenge-types/#http-01-challenge
// https://github.com/acmesh-official/acme.sh
server.use(
'/.well-known',
express.static(path.resolve(__dirname, '../.well-known'))
);

server.use(bodyParser.json({limit: '50mb'}));

// Only allow CORS for the <Analytics /> component
Expand Down
5 changes: 5 additions & 0 deletions helm/nginx-sidecar/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ data:
listen [::]:{{ .Values.port }};
{{- end }}
server_name _;

proxy_set_header X-Forwarded-For $proxy_protocol_addr; # To forward the original client's IP address
proxy_set_header X-Forwarded-Proto $scheme; # to forward the original protocol (HTTP or HTTPS)
proxy_set_header Host $host; # to forward the original host requested by the client

location / {
proxy_pass http://localhost:{{ .Values.internalPort }};
}
Expand Down

0 comments on commit 4c70bea

Please sign in to comment.