Jerod Santo

nginxparser: A Python module that loads and dumps Nginx configs

Even tiny, single-use open source tools are worthy of our attention. If you have the need to programmatically configure your Nginx servers, look no further than nginxparser by Fatih Erikli.

Weighing in at less than 100 lines of code, nginxparser provides two features.


from nginxparser import load

    [['server'], [
        ['listen', '80'],
        ['server_name', ''],
        ['root', '/home/ubuntu/sites/foo/']]]]

and dumping:

from nginxparser import dumps
dumps([['server'], [
    ['listen', '80'],
    ['server_name', ''],
    ['root', '/home/ubuntu/sites/foo/']]])

    'server {
        listen   80;
        root /home/ubuntu/sites/foo/;

I was impressed with how simple it is to define a parser using Pyparsing, which nginxparser does to great effect.

It’s definitely worth checking out!


Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00