通过python生成nginx模板配置文件
# cat config.py #coding=utf-8 nginx_conf = ''' server {{ listen {port}; server_name {servername}; access_log {access_log} main; location / {{ root {home}; index index.html index.htm; proxy_pass http://127.0.0.1:{proxy_port}; }} }} '''.format(port='8080', servername='cmdb', access_log='/var/log/nginx/cmdb.log',home='/data/python/cmdb/',proxy_port='9999') handle = open('cmdb.conf','w') handle.write(nginx_conf) handle.close()