1.0.1 • Published 7 years ago

nginx-vhost-manager v1.0.1

Weekly downloads
4
License
ISC
Repository
github
Last release
7 years ago

NginxVhostManager

Create, list and remove nginx virtualhosts (proxy) in seconds

You can also:

  • Reload nginx without errors

Requirments

The following commands must be executed as root, reple nodeUsername with the user that will run the node script

$ setfacl -m u:nodeUsername:rwx /etc/nginx/sites-available/
$ setfacl -m u:nodeUsername:rwx /etc/nginx/sites-enabled/

$ cd /etc/init.d/
$ touch node_nginx
$ echo "nodeUsername ALL=/etc/init.d/nginx" >> node_nginx
$ echo "nodeUsername ALL=NOPASSWD: /etc/init.d/nginx" >> node_nginx

Functions

    var vhost = require('./nginx-vhost-manager.js');

	vhost.addHost('test.es', 8088, function(err) {
		
	   if(err) {
	      console.log('error', err);	
	   } else {
	      console.log('done');	
	   }
		
	});
	
	vhost.removeHost('test.es', 8088, function(err) {
		
	   if(err) {
	      console.log('error', err);	
	   } else {
	      console.log('done');	
	   }
		
	});

    // List all created vhosts
	vhost.listHosts(function(data) {
	   console.log(data);	
	});