hobo05 / nginx-graph

A way to visualize nginx config files
MIT License
9 stars 4 forks source link
graph-objects nginx visualization

nginx-graph

A way to visualize nginx config files

Features

Technologies

Endpoints

How it works

Build Process

  1. Use npm to install dependencies
  2. Use webpack to process module *.js files into one compiled and optimized js file

Parsing

  1. Load nginx config file using the "readline" lib in node
  2. Parse nginx config sections into graph objects with properties
  3. Link graph objects to their parents during parsing
  4. Return graph objects as a json array

Rendering the diagram

  1. Define diagram properties
    • Make an ajax call to /data to get graph objects
    • Render diagram on callback

Source code highlighting

  1. Define code block in HTML
  2. Make an ajax call to /source and set the code block to the source
  3. Use highlightjs to highlight the code block on callback

How to run it locally

$ git clone https://github.com/hobo05/nginx-graph.git
$ cd nginx-graph
$ cp .env-example .env

Note: The reason we're using local-dev is because we're using nodemon to run the server instead of directly using node

How to run it in Heroku

Deploy

  1. After performing the local setup and seeing that everything works, sign up for Heroku on the free plan with the button above
    • Follow the tutorial for Getting Started on Heroku with Node.js if you don't know how Heroku works
    • Create a new Heroku app from your project root
    • Install https://github.com/xavdid/heroku-config and push your .env settings to heroku
    • Run heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt. This will tell heroku to run the Aptfile in the root of the project which installs necessary libraries for NodeGit before starting the app. See this github issue for more details
    • Run git push heroku master and it should be up in running in the cloud!