Skip to content

Commit 1ba2e91

Browse files
committed
build: Added more config generators
1 parent bf996f2 commit 1ba2e91

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

src/build/generate.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ function _createWebserverConfig(cfg, target, src, mimecb) {
5151
let tpl = _fs.readFileSync(src).toString();
5252
tpl = tpl.replace(/%DISTDIR%/, _path.join(ROOT, target));
5353
tpl = tpl.replace(/%MIMES%/, mimes);
54+
tpl = tpl.replace(/%PORT%/, cfg.server.http.port);
5455
return tpl;
5556
}
5657

@@ -117,6 +118,12 @@ const TASKS = {
117118
return Promise.resolve();
118119
},
119120

121+
'apache_proxy': function(cli, cfg) {
122+
const src = _path.join(ROOT, 'src', 'templates', 'webserver', 'apache-proxy.conf');
123+
124+
return Promise.resolve(_createWebserverConfig(cfg, '', src, function() {}));
125+
},
126+
120127
'lighttpd_config': function(cli, cfg) {
121128
const target = cli.option('target', 'dist');
122129

@@ -145,6 +152,12 @@ const TASKS = {
145152
}));
146153
},
147154

155+
'nginx_proxy': function(cli, cfg) {
156+
const src = _path.join(ROOT, 'src', 'templates', 'webserver', 'nginx-proxy.conf');
157+
158+
return Promise.resolve(_createWebserverConfig(cfg, '', src, function() {}));
159+
},
160+
148161
'package': function(cli, cfg) {
149162
let name = cli.option('name', '');
150163
const type = cli.option('type', 'application');

src/build/help.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ Configuration:
2828
config:add-mount --name=NAME --desc=DESC --path=PATH Adds a mountpoint
2929

3030
Generators:
31-
generate:apache-htaccess [--target=] Generates .htaccess file
32-
generate:apache-vhost --out=FILENAME [--target=] Generates a vhost file
33-
generate:nginx-config --out=FILENAME [--target=] Generates a nginx config
34-
generate:lighttpd-config --out=FILENAME [--target=] Generates a lighttpd config
31+
generate:apache-htaccess [--target=] Generates apache htaccess file (PHP)
32+
generate:apache-vhost --out=FILENAME [--target=] Generates apache vhost file (PHP)
33+
generate:apache-proxy --out=FILENAME Generates apache reverse-proxy (Node)
34+
generate:nginx-config --out=FILENAME [--target=] Generates nginx config (PHP)
35+
generate:nginx-proxy --out=FILENAME Generates nginx reverse-proxy (Node)
36+
generate:lighttpd-config --out=FILENAME [--target=] Generates lighttpd config (PHP)
3537
generate:package --name=REPO/NAME --type=TYPE Generates a new package
3638

3739
Misc:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<VirtualHost *:80>
2+
ServerName osjs.local
3+
ProxyPass / http://localhost:%PORT%/
4+
</VirtualHost>
5+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
server {
2+
listen 80;
3+
server_name osjs.local;
4+
5+
merge_slashes off; # This is very important
6+
location / { # Leading slash!
7+
proxy_set_header Host $host;
8+
proxy_set_header X-Real-IP $remote_addr;
9+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
10+
proxy_set_header X-Forwarded-Proto $scheme;
11+
proxy_pass http://localhost:%PORT%/; # The leading slash!
12+
proxy_redirect off; # Also note this
13+
proxy_http_version 1.1;
14+
proxy_set_header Upgrade $http_upgrade;
15+
proxy_set_header Connection 'upgrade';
16+
proxy_set_header Host $host;
17+
proxy_cache_bypass $http_upgrade;
18+
}
19+
}
20+

src/templates/webserver/nginx.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generated with `grunt nginx-config`
22
#
3-
# Tested with a completely fresh install of nginx and php5-fpm
3+
# Tested with a completely fresh install of nginx and php7-fpm
44
# on OSX and Ubuntu. All using default configuration files.
55
#
66
# This is using the default nginx.conf file values, just slimmed down
@@ -38,7 +38,7 @@ http {
3838
fastcgi_pass 127.0.0.1:9000;
3939

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

4343
fastcgi_split_path_info ^(.+\.php)(/.+)$;
4444
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

0 commit comments

Comments
 (0)