linemanjs / lineman

Lineman helps you build fat-client JavaScript apps. It produces happiness by building assets, mocking servers, running specs on every file change
MIT License
1.18k stars 83 forks source link

Added server.apiProxy.useSsl option to enable HTTP -> HTTPS API proxying #352

Closed ajwhitney closed 9 years ago

ajwhitney commented 9 years ago

There are environments where back-end services are only available via HTTPS and this enables the use of the very useful Lineman proxy in those environments.

This change includes a configuration point to enable proxying of back-end services via SSL/TLS. This is backward compatible (default is false). You opt-in to SSL by setting server.apiProxy.useSsl = true (and typically sever.apiProxy.port = 443).

Note: if your (intermediate) certs aren't recognized by nodejs (if you encounter the error UNABLE_TO_VERIFY_LEAF_SIGNATURE), you can force enable SSL communication (and assume the security risk) by adding "process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0'" in your application.js.

searls commented 9 years ago

Good job navigating the absolutely horrendous server.coffee task.

@davemo you've been using lineman lately, would you mind validating this locally?

davemo commented 9 years ago

This looks fine from a backwards compatibility and sensible default point of view; I haven't tested this locally with any meaningful configuration to see if it actually works -- I'm going to defer judgment on that to @ajwhitney. I'm assuming this has been tested in your local copy of Lineman @ajwhitney to ensure that it's solving your problems and not introducing any regressions?

ajwhitney commented 9 years ago

Yes @davemo. I am using this change and it appears to work fine with both HTTP and HTTPS backends. HTTP uses a backward compatible configuration (HTTPS requires the useSsl property, of course). It does not appear to me to be introducing any issues.

ajwhitney commented 9 years ago

I've updated the pull request to not include the API_USE_SSL environment variable

ajwhitney commented 9 years ago

BTW guys, we use Lineman everyday and have been very happy with it. It simply works great for us. Thank you very much for your hard work on it and for sharing it with the rest of us. I know it has taken a lot of time and effort and it is appreciated.

searls commented 9 years ago

@ajwhitney the quickest way to my merge button is, indeed, flattery.