diff --git a/src/build/generate.js b/src/build/generate.js index 4f612f25b1..77969baae7 100644 --- a/src/build/generate.js +++ b/src/build/generate.js @@ -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; } @@ -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'); @@ -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'); diff --git a/src/build/help.txt b/src/build/help.txt index 54348b3593..8403dedf1d 100644 --- a/src/build/help.txt +++ b/src/build/help.txt @@ -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: diff --git a/src/templates/webserver/apache-proxy.conf b/src/templates/webserver/apache-proxy.conf new file mode 100644 index 0000000000..3ef6070101 --- /dev/null +++ b/src/templates/webserver/apache-proxy.conf @@ -0,0 +1,5 @@ + + ServerName osjs.local + ProxyPass / http://localhost:%PORT%/ + + diff --git a/src/templates/webserver/nginx-proxy.conf b/src/templates/webserver/nginx-proxy.conf new file mode 100644 index 0000000000..199eadcee9 --- /dev/null +++ b/src/templates/webserver/nginx-proxy.conf @@ -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; + } +} + diff --git a/src/templates/webserver/nginx.conf b/src/templates/webserver/nginx.conf index 5a1ed04f53..cfa6fa6c29 100644 --- a/src/templates/webserver/nginx.conf +++ b/src/templates/webserver/nginx.conf @@ -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 @@ -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;