-->

Ember CLI Server Over HTTPS

2020-07-10 09:13发布

问题:

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.

回答1:

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 You can create self-signed certificates by following these instructions: https://devcenter.heroku.com/articles/ssl-certificate-self



回答2:

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.



回答3:

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