From 6d673c79a0c5e3a119bff6257a9d57a846915b4f Mon Sep 17 00:00:00 2001 From: cytopia Date: Mon, 30 Apr 2018 12:16:11 +0200 Subject: [PATCH 1/3] VHG-022 Add SSL support --- README.md | 7 +- bin/vhost_gen.py | 168 +++++++++++++++++++++++++++++++++---- etc/conf.yml | 9 ++ etc/templates/apache22.yml | 15 ++++ etc/templates/apache24.yml | 15 ++++ etc/templates/nginx.yml | 14 ++++ 6 files changed, 211 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 2d1a370..325cba8 100644 --- a/README.md +++ b/README.md @@ -215,7 +215,7 @@ If you are not satisfied with the `Allow from all` permissions, simply rewrite t #### Available command line options ```shell -Usage: vhost_gen.py -p|r -n [-l -c -t -o -d -s -v] +Usage: vhost_gen.py -p|r -n [-l -m -c -t -o -d -s -v] vhost_gen.py --help vhost_gen.py --version @@ -237,6 +237,11 @@ Required arguments: Note, this can also have a prefix and/or suffix to be set in conf.yml Optional arguments: + -m Vhost generation mode. Possible values are: + -m plain: Only generate http version (default) + -m ssl: Only generate https version + -m both: Generate http and https version + -m redir: Generate https version and make http redirect to https -c Path to global configuration file. If not set, the default location is /etc/vhost-gen/conf.yml If no config is found, a default is used with all features turned off. diff --git a/bin/vhost_gen.py b/bin/vhost_gen.py index 17a9237..1e59568 100755 --- a/bin/vhost_gen.py +++ b/bin/vhost_gen.py @@ -42,6 +42,7 @@ 'custom': '', 'vhost': { 'port': '80', + 'ssl_port': '443', 'name': { 'prefix': '', 'suffix': '' @@ -49,6 +50,13 @@ 'docroot': { 'suffix': '' }, + 'ssl': { + 'path_crt': '', + 'path_key': '', + 'honor_cipher_order': 'on', + 'ciphers': 'HIGH:!aNULL:!MD5', + 'protocols': 'TLSv1 TLSv1.1 TLSv1.2' + }, 'log': { 'access': { 'prefix': '', @@ -113,6 +121,11 @@ def print_help(): print(' Note, this can also have a prefix and/or suffix to be set in conf.yml') print('') print('Optional arguments:') + print(' -m Vhost generation mode. Possible values are:') + print(' -m plain: Only generate http version (default)') + print(' -m ssl: Only generate https version') + print(' -m both: Generate http and https version') + print(' -m redir: Generate https version and make http redirect to https') print(' -c Path to global configuration file.') print(' If not set, the default location is /etc/vhost-gen/conf.yml') print(' If no config is found, a default is used with all features turned off.') @@ -140,7 +153,7 @@ def print_help(): def print_version(): """Show program version.""" - print('vhost_gen v0.3 (2017-09-30)') + print('vhost_gen v0.4 (2018-04-29)') print('cytopia ') print('https://github.com/devilbox/vhost-gen') print('The MIT License (MIT)') @@ -232,13 +245,14 @@ def parse_args(argv): path = None name = None proxy = None + mode = None location = None default = False verbose = False # Define command line options try: - opts, argv = getopt.getopt(argv, 'vc:p:r:l:n:t:o:ds', ['version', 'help']) + opts, argv = getopt.getopt(argv, 'vm:c:p:r:l:n:t:o:ds', ['version', 'help']) except getopt.GetoptError as err: print('[ERR]', str(err), file=sys.stderr) print('Type --help for help', file=sys.stderr) @@ -264,6 +278,9 @@ def parse_args(argv): # Vhost reverse proxy (ADDR:PORT) elif opt == '-r': proxy = arg + # Mode overwrite + elif opt == '-m': + mode = arg # Location for reverse proxy elif opt == '-l': location = arg @@ -283,12 +300,12 @@ def parse_args(argv): save = True return ( - l_config_path, l_template_dir, o_template_dir, path, proxy, + l_config_path, l_template_dir, o_template_dir, path, proxy, mode, location, name, default, save, verbose ) -def validate_args_req(name, docroot, proxy, location): +def validate_args_req(name, docroot, proxy, mode, location): """Validate required arguments.""" # Validate required command line options are set if docroot is None and proxy is None: @@ -319,6 +336,13 @@ def validate_args_req(name, docroot, proxy, location): % (port), file=sys.stderr) sys.exit(1) + # Check mode string + if mode is not None: + if mode not in ('plain', 'ssl', 'both', 'redir'): + print('[ERR] Invalid -m mode string: \'%s\', should be: %s, %s, %s or %s' + % (mode, 'plain', 'ssl', 'both', 'redir'), file=sys.stderr) + sys.exit(1) + # Check normal server settings if docroot is not None: if location is not None: @@ -394,8 +418,14 @@ def validate_config(config): # Get vHost Skeleton placeholders ############################################################ -def vhost_get_port(config): +def vhost_get_port(config, ssl): """Get listen port.""" + if ssl: + if config['server'] == 'nginx': + return to_str(config['vhost']['ssl_port']) + ' ssl' + else: + return to_str(config['vhost']['ssl_port']) + return to_str(config['vhost']['port']) @@ -480,6 +510,42 @@ def vhost_get_vhost_rproxy(template, proxy, location): # Get vHost Features ############################################################ +def vhost_get_vhost_ssl(config, template, server_name): + """Get ssl definition.""" + return str_replace(template['features']['ssl'], { + '__SSL_PATH_CRT__': to_str(vhost_get_ssl_crt_path(config, server_name)), + '__SSL_PATH_KEY__': to_str(vhost_get_ssl_key_path(config, server_name)), + '__SSL_PROTOCOLS__': to_str(config['vhost']['ssl']['protocols']), + '__SSL_HONOR_CIPHER_ORDER__': to_str(config['vhost']['ssl']['honor_cipher_order']), + '__SSL_CIPHERS__': to_str(config['vhost']['ssl']['ciphers']) + }) + +def vhost_get_vhost_redir(config, template, server_name): + """Get redirect to ssl definition.""" + return str_replace(template['features']['redirect'], { + '__VHOST_NAME__': server_name, + '__SSL_PORT__': to_str(config['vhost']['ssl_port']) + }) + +def vhost_get_ssl_crt_path(config, server_name): + """Get ssl crt path""" + + prefix = to_str(config['vhost']['name']['prefix']) + suffix = to_str(config['vhost']['name']['suffix']) + name = prefix + server_name + suffix + '.crt' + + path = to_str(config['vhost']['ssl']['dir_crt']) + return os.path.join(path, name) + +def vhost_get_ssl_key_path(config, server_name): + """Get ssl key path""" + prefix = to_str(config['vhost']['name']['prefix']) + suffix = to_str(config['vhost']['name']['suffix']) + name = prefix + server_name + suffix + '.key' + + path = to_str(config['vhost']['ssl']['dir_crt']) + return os.path.join(path, name) + def vhost_get_docroot_path(config, docroot): """Get path of document root.""" suffix = to_str(config['vhost']['docroot']['suffix']) @@ -563,14 +629,16 @@ def vhost_get_custom_section(config): # vHost create ############################################################ -def get_vhost(config, tpl, docroot, proxy, location, server_name, default): - """Create the vhost.""" +def get_vhost_plain(config, tpl, docroot, proxy, mode, location, server_name, default): + """Get plain vhost""" return str_replace(tpl['vhost'], { - '__PORT__': vhost_get_port(config), + '__PORT__': vhost_get_port(config, False), '__DEFAULT_VHOST__': vhost_get_default_server(config, default), '__VHOST_NAME__': vhost_get_server_name(config, server_name, default), '__VHOST_DOCROOT__': str_indent(vhost_get_vhost_docroot(config, tpl, docroot, proxy), 4), '__VHOST_RPROXY__': str_indent(vhost_get_vhost_rproxy(tpl, proxy, location), 4), + '__REDIRECT__': '', + '__SSL__': '', '__INDEX__': vhost_get_index(config), '__ACCESS_LOG__': vhost_get_access_log(config, server_name), '__ERROR_LOG__': vhost_get_error_log(config, server_name), @@ -581,6 +649,73 @@ def get_vhost(config, tpl, docroot, proxy, location, server_name, default): '__CUSTOM__': str_indent(vhost_get_custom_section(config), 4) }) +def get_vhost_ssl(config, tpl, docroot, proxy, mode, location, server_name, default): + """Get ssl vhost""" + return str_replace(tpl['vhost'], { + '__PORT__': vhost_get_port(config, True), + '__DEFAULT_VHOST__': vhost_get_default_server(config, default), + '__VHOST_NAME__': vhost_get_server_name(config, server_name, default), + '__VHOST_DOCROOT__': str_indent(vhost_get_vhost_docroot(config, tpl, docroot, proxy), 4), + '__VHOST_RPROXY__': str_indent(vhost_get_vhost_rproxy(tpl, proxy, location), 4), + '__REDIRECT__': '', + '__SSL__': str_indent(vhost_get_vhost_ssl(config, tpl, server_name), 4), + '__INDEX__': vhost_get_index(config), + '__ACCESS_LOG__': vhost_get_access_log(config, server_name + '_ssl'), + '__ERROR_LOG__': vhost_get_error_log(config, server_name + '_ssl'), + '__PHP_FPM__': str_indent(vhost_get_php_fpm(config, tpl, docroot, proxy), 4), + '__ALIASES__': str_indent(vhost_get_aliases(config, tpl), 4), + '__DENIES__': str_indent(vhost_get_denies(config, tpl), 4), + '__SERVER_STATUS__': str_indent(vhost_get_server_status(config, tpl), 4), + '__CUSTOM__': str_indent(vhost_get_custom_section(config), 4) + }) + +def get_vhost_redir(config, tpl, docroot, proxy, mode, location, server_name, default): + """Get redirect to ssl vhost""" + return str_replace(tpl['vhost'], { + '__PORT__': vhost_get_port(config, False), + '__DEFAULT_VHOST__': vhost_get_default_server(config, default), + '__VHOST_NAME__': vhost_get_server_name(config, server_name, default), + '__VHOST_DOCROOT__': '', + '__VHOST_RPROXY__': '', + '__REDIRECT__': str_indent(vhost_get_vhost_redir(config, tpl, server_name), 4), + '__SSL__': '', + '__INDEX__': '', + '__ACCESS_LOG__': vhost_get_access_log(config, server_name), + '__ERROR_LOG__': vhost_get_error_log(config, server_name), + '__PHP_FPM__': '', + '__ALIASES__': '', + '__DENIES__': '', + '__SERVER_STATUS__': '', + '__CUSTOM__': '' + }) + + +def get_vhost(config, tpl, docroot, proxy, mode, location, server_name, default): + """Create the vhost.""" + + if mode == 'ssl': + return get_vhost_ssl(config, tpl, docroot, proxy, mode, location, + server_name, default) + elif mode == 'both': + return ( + get_vhost_ssl(config, tpl, docroot, proxy, mode, location, + server_name, default) + + get_vhost_plain(config, tpl, docroot, proxy, mode, location, + server_name, default) + ) + + elif mode == 'redir': + return ( + get_vhost_ssl(config, tpl, docroot, proxy, mode, location, + server_name, default) + + get_vhost_redir(config, tpl, docroot, proxy, mode, location, + server_name, default) + ) + + return get_vhost_plain(config, tpl, docroot, proxy, mode, location, + server_name, default) + + ############################################################ # Load configs and templates @@ -663,11 +798,11 @@ def main(argv): # Get command line arguments (config_path, tpl_dir, o_tpl_dir, docroot, - proxy, location, name, default, save, verbose) = parse_args(argv) + proxy, mode, location, name, default, save, verbose) = parse_args(argv) # Validate command line arguments This will abort the program on error # This will abort the program on error - validate_args_req(name, docroot, proxy, location) + validate_args_req(name, docroot, proxy, mode, location) validate_args_opt(config_path, tpl_dir) # Load config @@ -687,7 +822,7 @@ def main(argv): validate_config(config) # Retrieve fully build vhost - vhost = get_vhost(config, template, docroot, proxy, location, name, default) + vhost = get_vhost(config, template, docroot, proxy, mode, location, name, default) if verbose: print('vhostgen: [%s] Adding: %s' % @@ -708,14 +843,15 @@ def main(argv): vhost_path = os.path.join(config['conf_dir'], name+'.conf') with open(vhost_path, 'w') as outfile: outfile.write(vhost) + + # Apply settings for logging (symlinks, mkdir) only in save mode + succ, err = apply_log_settings(config) + if not succ: + print(err, file=sys.stderr) + sys.exit(1) else: print(vhost) - # Apply settings for logging - succ, err = apply_log_settings(config) - if not succ: - print(err, file=sys.stderr) - sys.exit(1) ############################################################ diff --git a/etc/conf.yml b/etc/conf.yml index fe55e56..ac6d4df 100644 --- a/etc/conf.yml +++ b/etc/conf.yml @@ -74,6 +74,7 @@ custom: vhost: # What port should this virtual host listen on port: 80 + ssl_port: 443 # The virtual host name is specified as an command line argument # to vhost_gen.py via '-n', however it is possible @@ -86,6 +87,14 @@ vhost: # to prepend another subdirectory here. docroot: suffix: htdocs + # SSL Definition + ssl: + dir_crt: /etc/httpd/cert + dir_key: /etc/httpd/cert + protocols: 'TLSv1 TLSv1.1 TLSv1.2' + honor_cipher_order: 'on' + ciphers: 'HIGH:!aNULL:!MD5' + # Log definition log: # Log file settings (error/access log) diff --git a/etc/templates/apache22.yml b/etc/templates/apache22.yml index c19ca51..35c4e27 100644 --- a/etc/templates/apache22.yml +++ b/etc/templates/apache22.yml @@ -51,6 +51,8 @@ vhost: | CustomLog "__ACCESS_LOG__" combined ErrorLog "__ERROR_LOG__" + __REDIRECT__ + __SSL__ __VHOST_DOCROOT__ __VHOST_RPROXY__ __PHP_FPM__ @@ -102,6 +104,19 @@ vhost_type: ### features: + # SSL Configuration + ssl: | + SSLEngine on + SSLCertificateFile "__SSL_PATH_CRT__" + SSLCertificateKeyFile "__SSL_PATH_KEY__" + SSLProtocol __SSL_PROTOCOLS__ + SSLHonorCipherOrder __SSL_HONOR_CIPHER_ORDER__ + SSLCipherSuite __SSL_CIPHERS__ + + # Redirect to SSL directive + redirect: | + RedirectMatch (.*) https://__VHOST_NAME__:__SSL_PORT__$1 + # PHP-FPM will not be applied to a reverse proxy! php_fpm: | # PHP-FPM Definition diff --git a/etc/templates/apache24.yml b/etc/templates/apache24.yml index 616e9f8..9befc55 100644 --- a/etc/templates/apache24.yml +++ b/etc/templates/apache24.yml @@ -51,6 +51,8 @@ vhost: | CustomLog "__ACCESS_LOG__" combined ErrorLog "__ERROR_LOG__" + __REDIRECT__ + __SSL__ __VHOST_DOCROOT__ __VHOST_RPROXY__ __PHP_FPM__ @@ -103,6 +105,19 @@ vhost_type: ### features: + # SSL Configuration + ssl: | + SSLEngine on + SSLCertificateFile "__SSL_PATH_CRT__" + SSLCertificateKeyFile "__SSL_PATH_KEY__" + SSLProtocol __SSL_PROTOCOLS__ + SSLHonorCipherOrder __SSL_HONOR_CIPHER_ORDER__ + SSLCipherSuite __SSL_CIPHERS__ + + # Redirect to SSL directive + redirect: | + RedirectMatch (.*) https://__VHOST_NAME__:__SSL_PORT__$1 + # PHP-FPM will not be applied to a reverse proxy! php_fpm: | # PHP-FPM Definition diff --git a/etc/templates/nginx.yml b/etc/templates/nginx.yml index 35a0655..c76f921 100644 --- a/etc/templates/nginx.yml +++ b/etc/templates/nginx.yml @@ -52,6 +52,8 @@ vhost: | access_log "__ACCESS_LOG__" combined; error_log "__ERROR_LOG__" warn; + __REDIRECT__ + __SSL__ __VHOST_DOCROOT__ __VHOST_RPROXY__ __PHP_FPM__ @@ -88,6 +90,18 @@ vhost_type: ### features: + # SSL Configuration + ssl: | + ssl_certificate __SSL_PATH_CRT__; + ssl_certificate_key __SSL_PATH_KEY__; + ssl_protocols __SSL_PROTOCOLS__; + ssl_prefer_server_ciphers __SSL_HONOR_CIPHER_ORDER__; + ssl_ciphers __SSL_CIPHERS__; + + # Redirect to SSL directive + redirect: | + return 301 https://__VHOST_NAME__:__SSL_PORT__$request_uri; + # PHP-FPM will not be applied to a reverse proxy! php_fpm: | # PHP-FPM Definition From ded91f21259294849b114a5fd37ec31558944324 Mon Sep 17 00:00:00 2001 From: cytopia Date: Mon, 30 Apr 2018 13:03:57 +0200 Subject: [PATCH 2/3] VHG-022 Python coding standards --- .pylintrc | 6 +-- bin/vhost_gen.py | 132 ++++++++++++++++++++++++----------------------- 2 files changed, 71 insertions(+), 67 deletions(-) diff --git a/.pylintrc b/.pylintrc index fdf7130..8a96888 100644 --- a/.pylintrc +++ b/.pylintrc @@ -339,7 +339,7 @@ single-line-if-stmt=no [DESIGN] # Maximum number of arguments for function / method -max-args=7 +max-args=8 # Maximum number of attributes for a class (see R0902). max-attributes=7 @@ -348,10 +348,10 @@ max-attributes=7 max-bool-expr=5 # Maximum number of branch for function / method body -max-branches=14 +max-branches=15 # Maximum number of locals for function / method body -max-locals=18 +max-locals=19 # Maximum number of parents for a class (see R0901). max-parents=7 diff --git a/bin/vhost_gen.py b/bin/vhost_gen.py index 1e59568..d209757 100755 --- a/bin/vhost_gen.py +++ b/bin/vhost_gen.py @@ -99,56 +99,58 @@ def print_help(): """Show program help.""" - print('Usage: vhost_gen.py -p|r -n [-l -c -t -o -d -s -v]') - print(' vhost_gen.py --help') - print(' vhost_gen.py --version') - print('') - print('vhost_gen.py will dynamically generate vhost configuration files') - print('for Nginx, Apache 2.2 or Apache 2.4 depending on what you have set') - print('in /etc/vhot-gen/conf.yml') - print('') - print('Required arguments:') - print(' -p|r You need to choose one of the mutually exclusive arguments.') - print(' -p: Path to document root/') - print(' -r: http(s)://Host:Port for reverse proxy.') - print(' Depening on the choice, it will either generate a document serving') - print(' vhost or a reverse proxy vhost.') - print(' Note, when using -p, this can also have a suffix directory to be set') - print(' in conf.yml') - print(' -l Location path when using reverse proxy.') - print(' Note, this is not required for normal document root server (-p)') - print(' -n Name of vhost') - print(' Note, this can also have a prefix and/or suffix to be set in conf.yml') - print('') - print('Optional arguments:') - print(' -m Vhost generation mode. Possible values are:') - print(' -m plain: Only generate http version (default)') - print(' -m ssl: Only generate https version') - print(' -m both: Generate http and https version') - print(' -m redir: Generate https version and make http redirect to https') - print(' -c Path to global configuration file.') - print(' If not set, the default location is /etc/vhost-gen/conf.yml') - print(' If no config is found, a default is used with all features turned off.') - print(' -t Path to global vhost template directory.') - print(' If not set, the default location is /etc/vhost-gen/templates/') - print(' If vhost template files are not found in this directory, the program will') - print(' abort.') - print(' -o Path to local vhost template directory.') - print(' This is used as a secondary template directory and definitions found here') - print(' will be merged with the ones found in the global template directory.') - print(' Note, definitions in local vhost teplate directory take precedence over') - print(' the ones found in the global template directory.') - print(' -d Make this vhost the default virtual host.') - print(' Note, this will also change the server_name directive of nginx to \'_\'') - print(' as well as discarding any prefix or suffix specified for the name.') - print(' Apache does not have any specialities, the first vhost takes precedence.') - print(' -s If specified, the generated vhost will be saved in the location found in') - print(' conf.yml. If not specified, vhost will be printed to stdout.') - print(' -v Be verbose.') - print('') - print('Misc arguments:') - print(' --help Show this help.') - print(' --version Show version.') + print(""" +Usage: vhost_gen.py -p|r -n [-l -c -t -o -d -s -v] + vhost_gen.py --help + vhost_gen.py --version + +vhost_gen.py will dynamically generate vhost configuration files +for Nginx, Apache 2.2 or Apache 2.4 depending on what you have set +in /etc/vhot-gen/conf.yml + +Required arguments: + -p|r You need to choose one of the mutually exclusive arguments. + -p: Path to document root/ + -r: http(s)://Host:Port for reverse proxy. + Depening on the choice, it will either generate a document serving + vhost or a reverse proxy vhost. + Note, when using -p, this can also have a suffix directory to be set + in conf.yml + -l Location path when using reverse proxy. + Note, this is not required for normal document root server (-p) + -n Name of vhost + Note, this can also have a prefix and/or suffix to be set in conf.yml + +Optional arguments: + -m Vhost generation mode. Possible values are: + -m plain: Only generate http version (default) + -m ssl: Only generate https version + -m both: Generate http and https version + -m redir: Generate https version and make http redirect to https + -c Path to global configuration file. + If not set, the default location is /etc/vhost-gen/conf.yml + If no config is found, a default is used with all features turned off. + -t Path to global vhost template directory. + If not set, the default location is /etc/vhost-gen/templates/ + If vhost template files are not found in this directory, the program will + abort. + -o Path to local vhost template directory. + This is used as a secondary template directory and definitions found here + will be merged with the ones found in the global template directory. + Note, definitions in local vhost teplate directory take precedence over + the ones found in the global template directory. + -d Make this vhost the default virtual host. + Note, this will also change the server_name directive of nginx to '_' + as well as discarding any prefix or suffix specified for the name. + Apache does not have any specialities, the first vhost takes precedence. + -s If specified, the generated vhost will be saved in the location found in + conf.yml. If not specified, vhost will be printed to stdout. + -v Be verbose. + +Misc arguments: + --help Show this help. + --version Show version. +""") def print_version(): @@ -423,8 +425,7 @@ def vhost_get_port(config, ssl): if ssl: if config['server'] == 'nginx': return to_str(config['vhost']['ssl_port']) + ' ssl' - else: - return to_str(config['vhost']['ssl_port']) + return to_str(config['vhost']['ssl_port']) return to_str(config['vhost']['port']) @@ -520,6 +521,7 @@ def vhost_get_vhost_ssl(config, template, server_name): '__SSL_CIPHERS__': to_str(config['vhost']['ssl']['ciphers']) }) + def vhost_get_vhost_redir(config, template, server_name): """Get redirect to ssl definition.""" return str_replace(template['features']['redirect'], { @@ -527,6 +529,7 @@ def vhost_get_vhost_redir(config, template, server_name): '__SSL_PORT__': to_str(config['vhost']['ssl_port']) }) + def vhost_get_ssl_crt_path(config, server_name): """Get ssl crt path""" @@ -537,6 +540,7 @@ def vhost_get_ssl_crt_path(config, server_name): path = to_str(config['vhost']['ssl']['dir_crt']) return os.path.join(path, name) + def vhost_get_ssl_key_path(config, server_name): """Get ssl key path""" prefix = to_str(config['vhost']['name']['prefix']) @@ -546,6 +550,7 @@ def vhost_get_ssl_key_path(config, server_name): path = to_str(config['vhost']['ssl']['dir_crt']) return os.path.join(path, name) + def vhost_get_docroot_path(config, docroot): """Get path of document root.""" suffix = to_str(config['vhost']['docroot']['suffix']) @@ -629,7 +634,7 @@ def vhost_get_custom_section(config): # vHost create ############################################################ -def get_vhost_plain(config, tpl, docroot, proxy, mode, location, server_name, default): +def get_vhost_plain(config, tpl, docroot, proxy, location, server_name, default): """Get plain vhost""" return str_replace(tpl['vhost'], { '__PORT__': vhost_get_port(config, False), @@ -649,7 +654,8 @@ def get_vhost_plain(config, tpl, docroot, proxy, mode, location, server_name, de '__CUSTOM__': str_indent(vhost_get_custom_section(config), 4) }) -def get_vhost_ssl(config, tpl, docroot, proxy, mode, location, server_name, default): + +def get_vhost_ssl(config, tpl, docroot, proxy, location, server_name, default): """Get ssl vhost""" return str_replace(tpl['vhost'], { '__PORT__': vhost_get_port(config, True), @@ -669,7 +675,8 @@ def get_vhost_ssl(config, tpl, docroot, proxy, mode, location, server_name, defa '__CUSTOM__': str_indent(vhost_get_custom_section(config), 4) }) -def get_vhost_redir(config, tpl, docroot, proxy, mode, location, server_name, default): + +def get_vhost_redir(config, tpl, server_name, default): """Get redirect to ssl vhost""" return str_replace(tpl['vhost'], { '__PORT__': vhost_get_port(config, False), @@ -694,29 +701,27 @@ def get_vhost(config, tpl, docroot, proxy, mode, location, server_name, default) """Create the vhost.""" if mode == 'ssl': - return get_vhost_ssl(config, tpl, docroot, proxy, mode, location, + return get_vhost_ssl(config, tpl, docroot, proxy, location, server_name, default) elif mode == 'both': return ( - get_vhost_ssl(config, tpl, docroot, proxy, mode, location, + get_vhost_ssl(config, tpl, docroot, proxy, location, server_name, default) + - get_vhost_plain(config, tpl, docroot, proxy, mode, location, + get_vhost_plain(config, tpl, docroot, proxy, location, server_name, default) ) elif mode == 'redir': return ( - get_vhost_ssl(config, tpl, docroot, proxy, mode, location, + get_vhost_ssl(config, tpl, docroot, proxy, location, server_name, default) + - get_vhost_redir(config, tpl, docroot, proxy, mode, location, - server_name, default) + get_vhost_redir(config, tpl, server_name, default) ) - return get_vhost_plain(config, tpl, docroot, proxy, mode, location, + return get_vhost_plain(config, tpl, docroot, proxy, location, server_name, default) - ############################################################ # Load configs and templates ############################################################ @@ -853,7 +858,6 @@ def main(argv): print(vhost) - ############################################################ # Main Entry Point ############################################################ From 0914a2f584809381b1646852b3d2f01f6bf51fc7 Mon Sep 17 00:00:00 2001 From: cytopia Date: Mon, 30 Apr 2018 13:13:46 +0200 Subject: [PATCH 3/3] VHG-022 Drop deprecated Python version --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 02f26cc..e63ebc7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,6 @@ language: python ### Python Build Matrix ### python: - - "2.6" - "2.7" - "3.2" - "3.3"