Skip to content

ddslConfigWriter generates new reverseProxy(nginx+++) config when new services are online in DDSL

Notifications You must be signed in to change notification settings

mbknor/ddslConfigWriter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DDSL Config Writer

Short description

ddslConfigWriter automatically reconfigures nginx (or any other reverse proxy) when you add or remove a server. Also decribed in this post

Longer description

ddslConfigWriter is a utility to write new configuration when the list of online services registered to DDSL changes.

ddslConfigWriter uses velocity template engine to generate documentation and can therefor be used to reconfigure:

  • Apache reverese proxy
  • Squid
  • nginx
  • any reverese proxy out there.

Currently only nginx reconfiguration is bundled but as you can see, it is really easy to confure any reverse proxy, using the templateing system.

How does it work?

ddslConfigWriter monitors DDSL for a specific service and (re)writes nginx-config (or any other reverse proxy) when the list of online services changes. Then it triggers reloading of the configuration.

It reads configuration from config.properties

How to test it?

Download and install zookeeper

start it:

zkServer start-foreground

Start an application that uses DDSL, for example ddsl-play2-producer-example

compile and stage it:

/path-to-play/play clean stage

start it (on this machine or any other machine):

target/start

It will broadcast to DDSL that it is online.

configure config.properties to query for this application.

start ddslConfigWriter:

sbt -DDDSL_CONFIG_PATH=../ddsl/ddsl-core/ddsl_config.properties run

It will write a new nginx config file: generatedConfig.conf

Start nginx with that config-file:

nginx -c /full-path/generatedConfig.conf

nginx now runs in the background listening on port 7080 and will forward trafic to the play app

Now we want to add another play server.

Start ddsl-play2-producer-example on a new port on this or any other server.

Dupicate the ddsl-play2-producer-example-folder (need different folder due to RUNNING_PID-file)

compile and stage it:

/path-to-play/play clean stage

run it on different port (on this machine or any other machine):

target/start -Dhttp.port=9001

when this new play-app starts up and registers to DDSL, ddslConfigWriter will detect it and write new and update config to generatedConfig.conf

ddslConfigWriter will then tell nginx to reload its configuration.

traffic will now be forwarded to the old app running on 9000 and the new app running on 9001

If you now quits the old app running on 9000, nginx will get reconfigured to only forward trafic to 9001.

About

ddslConfigWriter generates new reverseProxy(nginx+++) config when new services are online in DDSL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages