8

Is it possible to enable HTTPS protocol on Ember's CLI server? Our corporate OAuth system only allows redirects over HTTPS, so I'm in a bit of a bind without this.

ProfCrazynuts
  • 96
  • 1
  • 3

3 Answers3

15

Please note that as of ember-cli 0.2.6, Your app can be served over https. You just need to add your server.key and server.crt files in the ssl/ folder.

In your ember-cli file add

{
    ...,
    "ssl": true
}

You can also pass it as a command line argument ember s --ssl=true

Generating a self-signed certificate

Following these instructions (replicated here): https://devcenter.heroku.com/articles/ssl-certificate-self

Prerequisites

The openssl library is required to generate your own certificate. Run the following command in your local environment to see if you already have openssl installed installed.

which openssl
/usr/bin/openssl

If the which command does not return a path then you will need to install openssl yourself:

If you have… Install with…
Mac OS X Homebrew: brew install openssl
Windows Windows complete package .exe installer
Ubuntu Linux apt-get install openssl

Generate private key and certificate signing request

A private key and certificate signing request are required to create an SSL certificate. These can be generated with a few simple commands.

When the openssl req command asks for a “challenge password”, just press return, leaving the password empty. This password is used by Certificate Authorities to authenticate the certificate owner when they want to revoke their certificate. Since this is a self-signed certificate, there’s no way to revoke it via CRL (Certificate Revocation List).

More detailed instructions can be found in Creating an SSL Certificate Signing Request.

> openssl genrsa -aes256 -passout pass:gsahdg -out server.pass.key 4096
...
> openssl rsa -passin pass:gsahdg -in server.pass.key -out server.key
writing RSA key
> rm server.pass.key
openssl req -new -key server.key -out server.csr
...
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:California
...
A challenge password []:
...

Generate SSL certificate

The self-signed SSL certificate is generated from the server.key private key and server.csr files.

openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt

The server.crt file is your site certificate suitable for use with Heroku’s SSL add-on along with the server.key private key.

QuantumLicht
  • 2,103
  • 3
  • 23
  • 32
5

Edit: I believe I misunderstood the original question – see the answer above for how to do local development over SSL.

Ember CLI's server should never be used to serve an app in production. Ember apps are static files, and Ember CLI exists only to help you build those static files up.

Once you're ready to deploy your Ember CLI app, run ember build. This compiles your project down to a dist folder, which contains all the static assets. You can then deploy those using any web server you like.

Read more about deployments here: http://www.ember-cli.com/#deployments.

Sam Selikoff
  • 12,366
  • 13
  • 58
  • 104
  • 1
    I guess the question is about developing and debugging over HTTPS. Not deployments. – Lei Zhao Oct 13 '15 at 15:04
  • 2
    This should probably be ember cli should never be used to serve an app in production. There are lots of reasons to use SSL in development (at least one of which is in the question - testing single sign on with SSL) – jrjohnson Nov 09 '15 at 04:59
1

I'll preface this with @sam's answer: Please don't use this in a production environment.

Now, I'm not sure what your tech stack looks like, but when I was testing my app locally, and needed to proxy my requests through HTTPS, I used NGINX as a reverse proxy to my local server through SSL. (Note my server already happened to be running on NGINX so this was a very simple solution for me). I added this to my nginx.conf file:

server {
    listen *:4443; // Arbitrary Port Number

    location / {
        proxy_pass https://HOST_NAME:443/;
    }
}

And I ran my ember-server like this:

ember server --proxy http://HOST_NAME:4443
adambullmer
  • 952
  • 9
  • 29