(self,project_find)
return True
@name 设置Nginx配置
            @author hwliang<2021-08-09>
            @param project_find: dict<项目信息>
            @return bool
def set_nginx_config(self,project_find):
        '''
            @name 设置Nginx配置
            @author hwliang<2021-08-09>
            @param project_find: dict<项目信息>
            @return bool
        '''
        project_name = project_find['name']
        ports = []
        domains = []
        
        for d in project_find['project_config']['domains']:
            domain_tmp = d.split(':')
            if len(domain_tmp) == 1: domain_tmp.append(80)
            if not int(domain_tmp[1]) in ports: 
                ports.append(int(domain_tmp[1]))
            if not domain_tmp[0] in domains:
                domains.append(domain_tmp[0])
        listen_ipv6 = public.listen_ipv6()
        listen_ports = ''
        for p in ports:
            listen_ports += "    listen {};\n".format(p)
            if listen_ipv6:
                listen_ports += "    listen [::]:{};\n".format(p)
        listen_ports = listen_ports.strip()

        is_ssl,is_force_ssl = self.exists_nginx_ssl(project_name)
        ssl_config = ''
        if is_ssl:
            listen_ports += "\n    listen 443 ssl http2;"
            if listen_ipv6: listen_ports += "\n    listen [::]:443 ssl http2;"
        
            ssl_config = '''ssl_certificate    {vhost_path}/cert/{priject_name}/fullchain.pem;
    ssl_certificate_key    {vhost_path}/cert/{priject_name}/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";
    error_page 497  https://$host$request_uri;'''.format(vhost_path = self._vhost_path,priject_name = project_name)

            if is_force_ssl:
                ssl_config += '''
    #HTTP_TO_HTTPS_START
    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }
    #HTTP_TO_HTTPS_END'''
        
        config_file = "{}/nginx/node_{}.conf".format(self._vhost_path,project_name)
        template_file = "{}/template/nginx/node_http.conf".format(self._vhost_path)
        
        config_body = public.readFile(template_file)
        config_body = config_body.format(
            site_path = project_find['path'],
            domains = ' '.join(domains),
            project_name = project_name,
            panel_path = self._panel_path,
            log_path = public.get_logs_path(),
            url = 'http://127.0.0.1:{}'.format(project_find['project_config']['port']),
            host = '$host',
            listen_ports = listen_ports,
            ssl_config = ssl_config
        )

        # # 恢复旧的SSL配置
        # ssl_config = self.get_nginx_ssl_config(project_name)
        # if ssl_config:
        #     config_body.replace('#error_page 404/404.html;',ssl_config)
            

        rewrite_file = "{panel_path}/vhost/rewrite/node_{project_name}.conf".format(panel_path = self._panel_path,project_name = project_name)
        if not os.path.exists(rewrite_file): public.writeFile(rewrite_file,'# Please fill in the URLrewrite or custom NGINX config here\n')
        public.writeFile(config_file,config_body)
        return True
def set_nginx_config ( self , project_find ) : project_name = project_find [ 'name' ] ports = [ ] domains = [ ] for d in project_find [ 'project_config' ] [ 'domains' ] : domain_tmp = d . split ( ':' ) if len ( domain_tmp ) == 1 : domain_tmp . append ( 80 ) if not int ( domain_tmp [ 1 ] ) in ports : ports . append ( int ( domain_tmp [ 1 ] ) ) if not domain_tmp [ 0 ] in domains : domains . append ( domain_tmp [ 0 ] ) listen_ipv6 = public . listen_ipv6 ( ) listen_ports = '' for p in ports : listen_ports += "    listen {};\n" . format ( p ) if listen_ipv6 : listen_ports += "    listen [::]:{};\n" . format ( p ) listen_ports = listen_ports . strip ( ) is_ssl , is_force_ssl = self . exists_nginx_ssl ( project_name ) ssl_config = '' if is_ssl : listen_ports += "\n    listen 443 ssl http2;" if listen_ipv6 : listen_ports += "\n    listen [::]:443 ssl http2;" ssl_config = '''ssl_certificate    {vhost_path}/cert/{priject_name}/fullchain.pem;
    ssl_certificate_key    {vhost_path}/cert/{priject_name}/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";
    error_page 497  https://$host$request_uri;''' . format ( vhost_path = self . _vhost_path , priject_name = project_name ) if is_force_ssl : ssl_config += '''
    #HTTP_TO_HTTPS_START
    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }
    #HTTP_TO_HTTPS_END''' config_file = "{}/nginx/node_{}.conf" . format ( self . _vhost_path , project_name ) template_file = "{}/template/nginx/node_http.conf" . format ( self . _vhost_path ) config_body = public . readFile ( template_file ) config_body = config_body . format ( site_path = project_find [ 'path' ] , domains = ' ' . join ( domains ) , project_name = project_name , panel_path = self . _panel_path , log_path = public . get_logs_path ( ) , url = 'http://127.0.0.1:{}' . format ( project_find [ 'project_config' ] [ 'port' ] ) , host = '$host' , listen_ports = listen_ports , ssl_config = ssl_config ) # # 恢复旧的SSL配置 # ssl_config = self.get_nginx_ssl_config(project_name) # if ssl_config: #     config_body.replace('#error_page 404/404.html;',ssl_config) rewrite_file = "{panel_path}/vhost/rewrite/node_{project_name}.conf" . format ( panel_path = self . _panel_path , project_name = project_name ) if not os . path . exists ( rewrite_file ) : public . writeFile ( rewrite_file , '# Please fill in the URLrewrite or custom NGINX config here\n' ) public . writeFile ( config_file , config_body ) return True