今天弄了一个晚上没弄出来一个小东西,只弄出来了写追加,而且还是笨方法,起码死不掉那种。
1 global 2 log 127.0.0.1 local2 3 daemon 4 maxconn 256 5 log 127.0.0.1 local2 info 6 defaults 7 log global 8 mode http 9 timeout connect 5000ms 10 timeout client 50000ms 11 timeout server 50000ms 12 option dontlognull 13 14 listen stats :8888 15 stats enable 16 stats uri /admin 17 stats auth admin:1234 18 19 frontend oldboy.org 20 bind 0.0.0.0:80 21 option httplog 22 option httpclose 23 option forwardfor 24 log global 25 acl www hdr_reg(host) -i www.oldboy.org 26 use_backend www.oldboy.org if www 27 28 backend www.oldboy.org 29 server 100.1.7.9 100.1.7.9 weight 20 maxconn 3000 30 global 31 log 127.0.0.1 local2 32 daemon 33 maxconn 256 34 log 127.0.0.1 local2 info 35 defaults 36 log global 37 mode http 38 timeout connect 5000ms 39 timeout client 50000ms 40 timeout server 50000ms 41 option dontlognull 42 43 listen stats :8888 44 stats enable 45 stats uri /admin 46 stats auth admin:1234 47 48 frontend oldboy.org 49 bind 0.0.0.0:80 50 option httplog 51 option httpclose 52 option forwardfor 53 log global 54 acl www hdr_reg(host) -i www.oldboy.org 55 use_backend www.oldboy.org if www 56 57 backend www.oldboy.org 58 server 100.1.7.9 100.1.7.9 weight 20 maxconn 3000 59 global 60 log 127.0.0.1 local2 61 daemon 62 maxconn 256 63 log 127.0.0.1 local2 info 64 defaults 65 log global 66 mode http 67 timeout connect 5000ms 68 timeout client 50000ms 69 timeout server 50000ms 70 option dontlognull 71 72 listen stats :8888 73 stats enable 74 stats uri /admin 75 stats auth admin:1234 76 77 frontend oldboy.org 78 bind 0.0.0.0:80 79 option httplog 80 option httpclose 81 option forwardfor 82 log global 83 acl www hdr_reg(host) -i www.oldboy.org 84 use_backend www.oldboy.org if www 85 86 backend www.oldboy.org 87 server 100.1.7.9 100.1.7.9 weight 20 maxconn 3000 88 global 89 log 127.0.0.1 local2 90 daemon 91 maxconn 256 92 log 127.0.0.1 local2 info 93 defaults 94 log global 95 mode http 96 timeout connect 5000ms 97 timeout client 50000ms 98 timeout server 50000ms 99 option dontlognull 100 101 listen stats :8888 102 stats enable 103 stats uri /admin 104 stats auth admin:1234 105 106 frontend oldboy.org 107 bind 0.0.0.0:80 108 option httplog 109 option httpclose 110 option forwardfor 111 log global 112 acl www hdr_reg(host) -i www.oldboy.org 113 use_backend www.oldboy.org if www 114 115 backend www.oldboy.org 116 server 100.1.7.9 100.1.7.9 weight 20 maxconn 3000
具体就是最好一项backend的修改、追加、删除,只弄出来追加,下次再填坑。
具体代码如下
#增加 def add(a,b,c,d): backend_new = open('haproxy','a+') backend_new = backend_new.write('backend %s\n\t\tserver %s weight %s maxconn %s'%(a,b,c,d)) add( a = input('1.输入backend:'), b = input('2.输入server:'), c = input('3.输入weight:'), d = input('4.输入maxconn:') )
本来还以为def发现新大陆....