File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ LABEL \
2929 org.opencontainers.image.licenses="MIT"
3030WORKDIR /app
3131COPY --from=build /app /app
32- ENV HTTP_PORT=8080 HTTPS_PORT=8443
32+ ENV HTTP_PORT=8080 HTTPS_PORT=8443 HTTP_HOST=0.0.0.0 HTTPS_HOST=0.0.0.0
3333EXPOSE $HTTP_PORT $HTTPS_PORT
3434USER 1000
3535CMD ["node" , "./index.js" ]
Original file line number Diff line number Diff line change @@ -212,9 +212,9 @@ if(process.env.MTLS_ENABLE){
212212 }
213213}
214214
215- var httpServer = http . createServer ( httpOpts , app ) . listen ( process . env . HTTP_PORT || 8080 ) ;
216- var httpsServer = https . createServer ( httpsOpts , app ) . listen ( process . env . HTTPS_PORT || 8443 ) ;
217- console . log ( `Listening on ports ${ process . env . HTTP_PORT || 8080 } for http, and ${ process . env . HTTPS_PORT || 8443 } for https.` ) ;
215+ var httpServer = http . createServer ( httpOpts , app ) . listen ( process . env . HTTP_PORT || 8080 , process . env . HTTP_HOST || '0.0.0.0' ) ;
216+ var httpsServer = https . createServer ( httpsOpts , app ) . listen ( process . env . HTTPS_PORT || 8443 , process . env . HTTPS_HOST || '0.0.0.0' ) ;
217+ 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.` ) ;
218218
219219let calledClose = false ;
220220
Original file line number Diff line number Diff line change @@ -653,6 +653,22 @@ message " Stop containers "
653653docker stop http-echo-tests
654654sleep 5
655655
656+ message " Start container with different hostnames "
657+ 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
658+ sleep 5
659+ REQUEST=$( curl -s -k http://127.0.0.1:8080/hello-world)
660+ if [[ " $REQUEST " == " Hello World" ]]
661+ then
662+ passed " Different hostnames test passed."
663+ else
664+ failed " Different hostnames test failed."
665+ exit 1
666+ fi
667+
668+ message " Stop containers "
669+ docker stop http-echo-tests
670+ sleep 5
671+
656672popd
657673rm -rf testarea
658674message " DONE"
You can’t perform that action at this time.
0 commit comments