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

Method set_apache_config

class/projectModel/javaModel.py:1270–1368  ·  view source on GitHub ↗

@name 设置Apache配置 @author hwliang<2021-08-09> @param project_find: dict<项目信息> @return bool

(self, project_find)

Source from the content-addressed store, hash-verified

1268 return is_ssl, is_force_ssl
1269
1270 def set_apache_config(self, project_find):
1271 ''&#x27;
1272 @name 设置Apache配置
1273 @author hwliang<2021-08-09>
1274 @param project_find: dict<项目信息>
1275 @return bool
1276 ''&#x27;
1277 project_name = project_find['name']
1278
1279 # 处理域名和端口
1280 ports = []
1281 domains = []
1282 for d in project_find['project_config']['domains']:
1283 domain_tmp = d.split(':')
1284 if len(domain_tmp) == 1: domain_tmp.append(80)
1285 if not int(domain_tmp[1]) in ports:
1286 ports.append(int(domain_tmp[1]))
1287 if not domain_tmp[0] in domains:
1288 domains.append(domain_tmp[0])
1289
1290 config_file = "{}/apache/java_{}.conf".format(self._vhost_path, project_name)
1291 template_file = "{}/template/apache/java_http.conf".format(self._vhost_path)
1292 config_body = public.readFile(template_file)
1293 apache_config_body = ''
1294
1295 # 旧的配置文件是否配置SSL
1296 is_ssl, is_force_ssl = self.exists_apache_ssl(project_name)
1297 if is_ssl:
1298 if not 443 in ports: ports.append(443)
1299
1300 from panelSite import panelSite
1301 s = panelSite()
1302
1303 if project_find["project_config"]["java_type"] == "springboot":
1304 _site_path = project_find["project_config"]["jar_path"]
1305 else:
1306 _site_path = project_find['path']
1307
1308 # 根据端口列表生成配置
1309 for p in ports:
1310 # 生成SSL配置
1311 ssl_config = ''
1312 if p == 443 and is_ssl:
1313 ssl_key_file = "{vhost_path}/cert/{project_name}/privkey.pem".format(
1314 project_name = project_name, vhost_path = public.get_vhost_path()
1315 )
1316 if not os.path.exists(ssl_key_file): continue # 不存在证书文件则跳过
1317 ssl_config = ''&#x27;#SSL
1318 SSLEngine On
1319 SSLCertificateFile {vhost_path}/cert/{project_name}/fullchain.pem
1320 SSLCertificateKeyFile {vhost_path}/cert/{project_name}/privkey.pem
1321 SSLCipherSuite EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5
1322 SSLProtocol All -SSLv2 -SSLv3 -TLSv1
1323 SSLHonorCipherOrder On''&#x27;.format(project_name = project_name, vhost_path = public.get_vhost_path())
1324 else:
1325 if is_force_ssl:
1326 ssl_config = ''&#x27;#HTTP_TO_HTTPS_START
1327 <IfModule mod_rewrite.c>

Callers 2

set_configMethod · 0.95

Calls 11

exists_apache_sslMethod · 0.95
panelSiteClass · 0.90
readFileMethod · 0.80
writeFileMethod · 0.80
splitMethod · 0.45
appendMethod · 0.45
formatMethod · 0.45
existsMethod · 0.45
joinMethod · 0.45
apacheAddPortMethod · 0.45

Tested by

no test coverage detected