()
| 163 | |
| 164 | @staticmethod |
| 165 | def _set_nginx_proxy_base(): |
| 166 | file = "/www/server/nginx/conf/proxy.conf" |
| 167 | setup_path = "/www/server" |
| 168 | if not os.path.exists(file): |
| 169 | conf = '''proxy_temp_path %s/nginx/proxy_temp_dir; |
| 170 | proxy_cache_path %s/nginx/proxy_cache_dir levels=1:2 keys_zone=cache_one:10m inactive=1d max_size=5g; |
| 171 | client_body_buffer_size 512k; |
| 172 | proxy_connect_timeout 60; |
| 173 | proxy_read_timeout 60; |
| 174 | proxy_send_timeout 60; |
| 175 | proxy_buffer_size 32k; |
| 176 | proxy_buffers 4 64k; |
| 177 | proxy_busy_buffers_size 128k; |
| 178 | proxy_temp_file_write_size 128k; |
| 179 | proxy_next_upstream error timeout invalid_header http_500 http_503 http_404; |
| 180 | proxy_cache cache_one;''' % (setup_path, setup_path) |
| 181 | write_file(file, conf) |
| 182 | |
| 183 | conf = read_file(file) |
| 184 | if conf and conf.find('include proxy.conf;') == -1: |
| 185 | conf = re.sub(r"include\s+mime\.types;", "include mime.types;\n\tinclude proxy.conf;", conf) |
| 186 | write_file(file, conf) |
| 187 | |
| 188 | # websocket前置map |
| 189 | map_file = "/www/server/panel/vhost/nginx/0.websocket.conf" |
| 190 | if not os.path.exists(map_file): |
| 191 | write_file(map_file, ''' |
| 192 | map $http_upgrade $connection_upgrade { |
| 193 | default upgrade; |
| 194 | '' close; |
| 195 | }''') |
| 196 | |
| 197 | @staticmethod |
| 198 | def build_proxy_conf(proxy_data: dict) -> str: |
no test coverage detected