nginx-vhost-manager

1.0.1 • Public • Published

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);
    });

Readme

Keywords

none

Package Sidebar

Install

npm i nginx-vhost-manager

Weekly Downloads

0

Version

1.0.1

License

ISC

Last publish

Collaborators

  • lluiscab