MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / _set_nginx_proxy_base

Method _set_nginx_proxy_base

mod/project/java/server_proxy.py:165–195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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;
170proxy_cache_path %s/nginx/proxy_cache_dir levels=1:2 keys_zone=cache_one:10m inactive=1d max_size=5g;
171client_body_buffer_size 512k;
172proxy_connect_timeout 60;
173proxy_read_timeout 60;
174proxy_send_timeout 60;
175proxy_buffer_size 32k;
176proxy_buffers 4 64k;
177proxy_busy_buffers_size 128k;
178proxy_temp_file_write_size 128k;
179proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
180proxy_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, '''
192map $http_upgrade $connection_upgrade {
193 default upgrade;
194 '' close;
195}''')
196
197 @staticmethod
198 def build_proxy_conf(proxy_data: dict) -> str:

Callers 2

create_proxyMethod · 0.95
modify_proxyMethod · 0.95

Calls 5

write_fileFunction · 0.90
read_fileFunction · 0.90
existsMethod · 0.45
findMethod · 0.45
subMethod · 0.45

Tested by

no test coverage detected