Skip to content

Instantly share code, notes, and snippets.

@robabby
Forked from leandrocp/Brocfile
Created November 13, 2017 01:29
Show Gist options
  • Save robabby/573fd114c49510ed5d8f6f1487113ebe to your computer and use it in GitHub Desktop.
Save robabby/573fd114c49510ed5d8f6f1487113ebe to your computer and use it in GitHub Desktop.
Deploy ember-cli app on nginx
/* global require, module */
// Prepend app name on assets names
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var app = new EmberApp({
fingerprint: {
enabled: true,
prepend: '/appX/'
}
});
module.exports = app.toTree();
/* jshint node: true */
// BaseURL
module.exports = function(environment) {
var ENV = {
modulePrefix: 'appX',
baseURL: '/appX',
// ...
}
// ...
};
# Nginx Ember
# leandrocp
# https://gist.github.com/leandrocp/c7be4b9f2618cd2d2620
# https://github.com/tonycoco/heroku-buildpack-ember-cli/blob/70a7f56760a23ffea022dd2c1eb21d3a7b37a7b2/config/nginx.conf.erb
#
# Expected directory hierarchy
#
# ├── /var/www/apps
# | ├── app1
# | │ ├── assets
# | │ ├── index.html
# | ├── app2
# | │ ├── assets
# | │ ├── index.html
daemon off;
worker_processes 1;
events {
worker_connections 1024;
}
http {
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_comp_level 2;
gzip_min_length 512;
gzip_proxied any;
gzip_vary on;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server_tokens off;
tcp_nopush on;
tcp_nodelay on;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/nginx/access.log main;
error_log logs/nginx/error.log;
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
listen 8080;
server_name _;
keepalive_timeout 5;
index index.html;
root /var/www/apps/;
location ~* \.(ogg|ogv|svgz|mp4|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|html|txt|htm|eot|oft|svg|ttf|woff)$ {
expires max;
add_header Cache-Control public;
add_header X-Ember-Assets on;
}
location ~ /(.+)/ {
alias /var/www/apps/$1/;
add_header X-Ember-Application $1;
try_files $uri $uri/ /index.html =404 break;
}
location ~ /\. {
deny all;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment