Skip to content

Commit

Permalink
build: Added more config generators
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Feb 5, 2017
1 parent bf996f2 commit 1ba2e91
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/build/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function _createWebserverConfig(cfg, target, src, mimecb) {
let tpl = _fs.readFileSync(src).toString();
tpl = tpl.replace(/%DISTDIR%/, _path.join(ROOT, target));
tpl = tpl.replace(/%MIMES%/, mimes);
tpl = tpl.replace(/%PORT%/, cfg.server.http.port);
return tpl;
}

Expand Down Expand Up @@ -117,6 +118,12 @@ const TASKS = {
return Promise.resolve();
},

'apache_proxy': function(cli, cfg) {
const src = _path.join(ROOT, 'src', 'templates', 'webserver', 'apache-proxy.conf');

return Promise.resolve(_createWebserverConfig(cfg, '', src, function() {}));
},

'lighttpd_config': function(cli, cfg) {
const target = cli.option('target', 'dist');

Expand Down Expand Up @@ -145,6 +152,12 @@ const TASKS = {
}));
},

'nginx_proxy': function(cli, cfg) {
const src = _path.join(ROOT, 'src', 'templates', 'webserver', 'nginx-proxy.conf');

return Promise.resolve(_createWebserverConfig(cfg, '', src, function() {}));
},

'package': function(cli, cfg) {
let name = cli.option('name', '');
const type = cli.option('type', 'application');
Expand Down
10 changes: 6 additions & 4 deletions src/build/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ Configuration:
config:add-mount --name=NAME --desc=DESC --path=PATH Adds a mountpoint

Generators:
generate:apache-htaccess [--target=] Generates .htaccess file
generate:apache-vhost --out=FILENAME [--target=] Generates a vhost file
generate:nginx-config --out=FILENAME [--target=] Generates a nginx config
generate:lighttpd-config --out=FILENAME [--target=] Generates a lighttpd config
generate:apache-htaccess [--target=] Generates apache htaccess file (PHP)
generate:apache-vhost --out=FILENAME [--target=] Generates apache vhost file (PHP)
generate:apache-proxy --out=FILENAME Generates apache reverse-proxy (Node)
generate:nginx-config --out=FILENAME [--target=] Generates nginx config (PHP)
generate:nginx-proxy --out=FILENAME Generates nginx reverse-proxy (Node)
generate:lighttpd-config --out=FILENAME [--target=] Generates lighttpd config (PHP)
generate:package --name=REPO/NAME --type=TYPE Generates a new package

Misc:
Expand Down
5 changes: 5 additions & 0 deletions src/templates/webserver/apache-proxy.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<VirtualHost *:80>
ServerName osjs.local
ProxyPass / http://localhost:%PORT%/
</VirtualHost>

20 changes: 20 additions & 0 deletions src/templates/webserver/nginx-proxy.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
server {
listen 80;
server_name osjs.local;

merge_slashes off; # This is very important
location / { # Leading slash!
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:%PORT%/; # The leading slash!
proxy_redirect off; # Also note this
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

4 changes: 2 additions & 2 deletions src/templates/webserver/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated with `grunt nginx-config`
#
# Tested with a completely fresh install of nginx and php5-fpm
# Tested with a completely fresh install of nginx and php7-fpm
# on OSX and Ubuntu. All using default configuration files.
#
# This is using the default nginx.conf file values, just slimmed down
Expand Down Expand Up @@ -38,7 +38,7 @@ http {
fastcgi_pass 127.0.0.1:9000;

# PHP FPM
#fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_pass unix:/var/run/php7-fpm.sock;

fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Expand Down

0 comments on commit 1ba2e91

Please sign in to comment.