GithubHelp home page GithubHelp logo

phanan / virtualmin-nginx-config-hook Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 1.0 160 KB

A Virtualmin hook to generate a nginx server config file post Apache server setup

License: MIT License

Shell 100.00%

virtualmin-nginx-config-hook's Introduction

virtualmin-nginx-config-hook

A Virtualmin hook to generate a nginx server config file post-Apache server setup.

Why?

  • You have a dedicated server or a VPS
  • You have a LAMP stack beautifully set up and configured
  • You use Virtualmin as the web hosting control panel of choice
  • You have Apache proxied by a public-facing nginx, because performance
  • You have to manually create and manage those nginx .conf files after setting up a host in Virtualmin, and
  • You are too lazy for this shit feel like your time can be used for something better

How?

Virtualmin can be configured to run a command (hook) before and after making changes to a server. In the command context, a lot of global variables are pre-populated by Virtualmin, ready to use. For example:

uid=500
name=1
postgres=0
web_port=8000
limit_mysql=1
limit_ssl=0

Take a look at sample-dom-file for a more complete example.

All of these variable names will be available with a $VIRTUALSERVER_ prefix, e.g. $VIRTUALSERVER_UID, $VIRTUALSERVER_DOM etc. Making use of them, we can write a shellscript to automate creating and managing the nginx config files on the fly.

No, really, how?

Oh ok...

git clone [email protected]:phanan/virtualmin-nginx-config-hook.git
chmod +x virtualmin-nginx-config-hook/hook

Then, configure the post domain modification script to point to hook's full path. Now whenever you create or modify a (sub)domain via Virtualmin interface, these things should happen, in that order:

  1. A file in the format of {domain_name}.conf is generated under {nginx_conf_dir}/sites-available
  2. A symbolic link pointing to said file is created under {nginx_conf_dir}/sites-enabled
  3. nginx service is then reloaded and ready to serve

When you delete the (sub)domain, both the file and its symlink are removed.

Configuration

The hook works with the assumption that your nginx is configured to read domain config files from sites-enabled and sites-available directories, following the (arguably) most common practice. Additionally, these variables can be configured to fit your needs:

NGINX_CONF_DIR="/etc/nginx"
NGINX_PORT=80
NGINX_SSL_PORT=443

Other than that... not so much, sorry.

Known Limitations

  • Upon Virtualmin domain update, the corresponding .conf file's content will be completely reset. If you have any custom modifications, they will be gone into oblivion.
  • Domain disabling and re-enabling are not supported yet.

Disclaimer and License

MIT © Phan An.

This package is created and shared with hope that it may help someone out there, but its owner shouldn't take any responsibility for any claim, damages or other liability whatsoever. See LICENSE.

virtualmin-nginx-config-hook's People

Contributors

phanan avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

rubythonode

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.