Skip to content

Instantly share code, notes, and snippets.

@mpilar
Last active January 14, 2016 20:29
Show Gist options
  • Save mpilar/d7946e580cb2fb108051 to your computer and use it in GitHub Desktop.
Save mpilar/d7946e580cb2fb108051 to your computer and use it in GitHub Desktop.
files:
"/etc/nginx/conf.d/000_shop_config.conf":
mode: "000644"
content: |
client_max_body_size 100m;
client_body_buffer_size 128k;
proxy_buffering on;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
"/tmp/nginx_fix":
mode: "000744"
content: |
#! /usr/bin/env node
ngcf = require('nginx-conf').NginxConfFile;
confPath = '/etc/nginx/conf.d/webapp_healthd.conf';
wsLocation = '/websocket';
function isWSLocation(locStanza) {
return locStanza.toString().indexOf(wsLocation) != -1;
}
ngcf.create(confPath, function(err, conf) {
if (err) {
console.log(err);
return;
}
var confLocations = conf.nginx.server.location;
var wsStanza = confLocations.filter(isWSLocation).pop();
if ( wsStanza === undefined ) {
conf.nginx.server._add('location', wsLocation);
wsStanza = confLocations[confLocations.length-1];
wsStanza._add('proxy_pass', 'http://my_app');
wsStanza._add('proxy_http_version', '1.1');
wsStanza._add('proxy_set_header', 'Host $host');
wsStanza._add('proxy_set_header', 'X-Forwarded-For $proxy_add_x_forwarded_for');
wsStanza._add('proxy_set_header', 'Upgrade $http_upgrade');
wsStanza._add('proxy_set_header', 'Connection "upgrade"');
}
conf.flush();
});
container_commands:
01npm:
env:
NODE_PATH: "/usr/lib/node_modules"
command: "npm install --global nginx-conf"
02run_nginx_fix:
env:
NODE_PATH: "/usr/lib/node_modules"
command: "/tmp/nginx_fix"
03rm_nginx_fix:
command: "rm /tmp/nginx_fix"
99restart_nginx:
command: "service nginx restart"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment