micromata / http-fake-backend

Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
MIT License
311 stars 22 forks source link

feature: Make it possible to use HTTPS #19

Open dqvn opened 6 years ago

dqvn commented 6 years ago

Dear,

Please help/show me how to add more configuration in order to run this server under Https with SSL I am using your project, but we need to switch it to HTTPS rather than current normal HTTP.

Best regards, Quang Nguyen dqvn2002@gmail.com

mischah commented 6 years ago

Hej @dqvn,

you need to provide tls options over here: https://github.com/micromata/http-fake-backend/blob/6f77e92e0ec6b8019a1118202d5eef097af1ac5a/manifest.js#L36-L39

like described here.

Cheers, Michael


Going to leave this open, because it might be a feature which others may also need.

We could make this configurable via https://github.com/micromata/http-fake-backend/blob/master/.env

taumartin commented 4 years ago

Hi, would it be too much to ask you to show me a more detailed example of what the manifest file would look like? Thanks in advance.

mppperez commented 2 years ago

Hi @taumartin,

a little bit late but this may help someone else:

you have to add tls in connections (see above) with specifying the private key and certificate (chain). I had to add the encoding as well since otherwise I got an exception due to invalid format.

Example:

connections: [{
        port: Config.get('/port/web'),
        labels: ['web'],
        tls: {
            key: fs.readFileSync('/path/to/your/certs/key.pem', 'utf8'),
            cert: fs.readFileSync('/path/to/your/certs/cert.pem', 'utf8')
        }
    }],