DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

`docker run -p 127.0.0.1:8080:8080`? and if not, do I need SSL certificate?

It is this repo, actually; powered by fastify.

About SSL, I can try docker run -p 8080:8080, but then I would need to access http://0.0.0.0:8080 which gets permanent redirect (301) to https, but then, I don't have local HTTPS. (I rely on Heroku's for online.)

I think the culprit is Chrome's security itself.

Ok, I decided to ask on StackOverflow.

And also reproducible is this repo https://github.com/patarapolw/docker0000

I am opening http://localhost:8080 in Chrome Version 80.0.3987.163 (Official Build) (64-bit) / macOS 10.15.3 MacAir 15 inch

It gets redirected to https://localhost:8080 every time.

├── package.json
├── public
│   └── index.html
├── server.js
├── .dockerignore
└── Dockerfile
// server.js

const app = require('express')()

Top comments (3)

Collapse
 
manishfoodtechs profile image
manish srivastava

Local Host by default accessible on both https and http.
Check Fastify Helmet.

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

Can reproduce now.

It is only a problem with serve-static; not REST API's. And also a problem with Express.

Collapse
 
manishfoodtechs profile image
manish srivastava • Edited

great. Another thing:
You get SSL certificate for Full Qualified Domain Names (FQDN). Though there are certain services that provide IP SSL but still you will get a certificate error in chrome family browsers. However, IP SSL is good if enrcyption is required.But generally avoided and FQDN is best way.