Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
131 lines (95 sloc) 3.75 KB
layout title permalink category github
post
Deployments
deployments
user-guide

You can easily deploy your Ember CLI application to a number of places using ember-cli-deploy.

Additional Examples:

History API and Root URL

If you are deploying the app to somewhere other than the rootURL (/), you will need to configure the value of rootURL in config/environment.js. This is required for the History API, and thus also the Router, to function correctly.

For example

{% highlight javascript %} // config/environment.js if (environment === 'production') { ENV.rootURL = '/path/to/ember/app/'; } {% endhighlight %}

This will also be used as a prefix for assets, eg /path/to/ember/app/assets/vendor.js. However when building for production the value of prepend for fingerprint will be used instead. So for

{% highlight bash %} ember build --prod {% endhighlight %}

with

{% highlight javascript %} // ember-cli-build.js const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) { let app = new EmberApp(defaults, { // Add options here fingerprint: { prepend: 'https://cdn.example.com/' } });

return app.toTree(); }; {% endhighlight %}

the asset URLs will not use rootURL and will instead be: https://cdn.example.com/assets/vendor-3b1b39893d8e34a6d0bd44095afcd5c4.js.

As of version 2.7, baseURL is deprecated and rootURL should be used instead. See this blog post for more details.

Content Security Policy

For those interested in enhanced security for their web application, they should consider the setting up a content-security policy even for development. That way security violations can be discovered immediately, rather than in production.

For more information, see the ember-cli-content-security-policy README.

Deploying an HTTPS server using Nginx on a Unix/Linux/MacOSx machine

The following is a simple deployment with https using nginx. Http just redirects to the https server here. Don't forget to include your ssl keys in your config.

Before deployment make sure you run this command to populate the dist directory:

{% highlight bash %} ember build --environment="production" {% endhighlight %}

File: nginx.conf

## Nginx Production Https Ember Server Configuration

## https site##
server {
    listen      443 default;
    server_name <your-server-name>;
    #root        /usr/share/nginx/html;
    root        <root path to an ember /dist directory>;
    index       index.html index.htm;

    # log files
    access_log  /var/log/nginx/<your-server-name>.access.log;
    error_log   /var/log/nginx/<your-server-name>.error.log;

    # ssl files
    ssl on;
    keepalive_timeout   60;

    # include information on SSL keys, cert, protocols and ciphers
    # SSLLabs.com is a great resource for this, along with testing
    # your SSL configuration: https://www.ssllabs.com/projects/documentation/
    
    # Strict Transport Security
    add_header Strict-Transport-Security max-age=2592000;

    # proxy buffers
    proxy_buffers 16 64k;
    proxy_buffer_size 128k;

    ## default location ##
    location / {
        include /etc/nginx/mime.types;
        try_files $uri $uri/ /index.html?/$request_uri;
    }

}

## http redirects to https ##
server {
    listen      80;
    server_name <your-server-name>;

    rewrite ^/.*$ https://$host$request_uri? permanent;
}