Skip to content
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ LABEL \
org.opencontainers.image.licenses="MIT"
WORKDIR /app
COPY --from=build /app /app
ENV HTTP_PORT=8080 HTTPS_PORT=8443
ENV HTTP_PORT=8080 HTTPS_PORT=8443 HTTP_HOST=0.0.0.0 HTTPS_HOST=0.0.0.0
EXPOSE $HTTP_PORT $HTTPS_PORT
USER 1000
CMD ["node", "./index.js"]
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ if(process.env.MTLS_ENABLE){
}
}

var httpServer = http.createServer(httpOpts, app).listen(process.env.HTTP_PORT || 8080);
var httpsServer = https.createServer(httpsOpts,app).listen(process.env.HTTPS_PORT || 8443);
console.log(`Listening on ports ${process.env.HTTP_PORT || 8080} for http, and ${process.env.HTTPS_PORT || 8443} for https.`);
var httpServer = http.createServer(httpOpts, app).listen(process.env.HTTP_PORT || 8080, process.env.HTTP_HOST || '0.0.0.0');
var httpsServer = https.createServer(httpsOpts,app).listen(process.env.HTTPS_PORT || 8443, process.env.HTTPS_HOST || '0.0.0.0');
console.log(`Listening on ${process.env.HTTP_HOST || '0.0.0.0'}:${process.env.HTTP_PORT || 8080} for http, and ${process.env.HTTPS_HOST || '0.0.0.0'}:${process.env.HTTPS_PORT || 8443} for https.`);

let calledClose = false;

Expand Down
16 changes: 16 additions & 0 deletions tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,22 @@ message " Stop containers "
docker stop http-echo-tests
sleep 5

message " Start container with different hostnames "
docker run -d --rm -e HTTP_HOST=127.0.0.1 -e HTTPS_HOST=127.0.0.1 --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing
sleep 5
REQUEST=$(curl -s -k http://127.0.0.1:8080/hello-world)
if [[ "$REQUEST" == "Hello World" ]]
then
passed "Different hostnames test passed."
else
failed "Different hostnames test failed."
exit 1
fi

message " Stop containers "
docker stop http-echo-tests
sleep 5

popd
rm -rf testarea
message "DONE"