Skip to content

Instantly share code, notes, and snippets.

@jhseodev
Created December 3, 2019 01:13
Show Gist options
  • Save jhseodev/8698402f0c17a99de0e294dbfe5c79e6 to your computer and use it in GitHub Desktop.
Save jhseodev/8698402f0c17a99de0e294dbfe5c79e6 to your computer and use it in GitHub Desktop.
nginx map parser
from reconfigure.parsers import NginxParser
conf = '''map $ssl_server_name $proxy_tcp {
hostnames;
default upstream_tcp;
*.test.com upstream_tcp2;
"~*test[1-9].com" upstream_tcp3;
}
'''
def main():
np = NginxParser()
np.tokens.append((r".+?;", lambda s, t: ('option', t)))
print np.parse(conf)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment