TypeError: string indices must be integers, not str” from apache_status plugin

I am no expert in Python and i am using this plugin. I require this to work. Any help will be greatly appreciated.
The part of plugin

#!/usr/bin/python
      
def get_config():
    config_dir = os.getenv("MK_CONFDIR", "/etc/check_mk")
    config_file = config_dir + "/apache_status.conf"

    if not os.path.exists(config_file):
        config_file = config_dir + "/apache_status.cfg"

    # None or tuple of ((proto, cacert), ipaddress, port, instance_name).
    #  - proto is 'http' or 'https'
    #  - cacert is a path to a CA certificate, or None
    #  - port may be None
    #  - instance_name may be the empty string
    config = {
        "servers": None,
        "ssl_ports": [443],
    }
    if os.path.exists(config_file):
        execfile(config_file, config)
    return config

    def try_detect_servers(ssl_ports):
    results = []

    for netstat_line in os.popen('netstat -tlnp 2>/dev/null').readlines():
        parts = netstat_line.split()
        # Skip lines with wrong format
        if len(parts) < 7 or '/' not in parts[6]:
            continue

        server_address, server_port = parts[3].rsplit(':', 1)
        server_port = int(server_port)

        # Use localhost when listening globally
        if server_address == '0.0.0.0':
            server_address = '127.0.0.1'
        elif server_address == '::':
            server_address = '[::1]'
        elif ':' in server_address:
            server_address = '[%s]' % server_address

        # Switch protocol if port is SSL port. In case you use SSL on another
        # port you would have to change/extend the ssl_port list
        if server_port in ssl_ports:
            scheme = 'https'
        else:
            scheme = 'http'

        results.append((scheme, server_address, server_port))

    return results  

def _unpack(config):
    if isinstance(config, tuple):
        if len(config) == 3:
            # Append empty instance name.
            config += ("",)
        if not isinstance(config[0], tuple):
            # Set cacert option.
            config = ((config[0], None),) + config[1:]
        return config + ("server-status",)
    *return ((config['protocol'], config.get('cafile', None)), config['address'], config['port'],*
            config.get("instance", ""), config.get('page', 'server-status'))
.....

My config (apache-status.cfg)

servers = ['127.0.0.1']
ssl_ports = [443]
protocol=['https']
port=[443]

whatever changes i make here, it throws the same error.

Error:

Traceback (most recent call last):
  File "./a", line 209, in <module>
    sys.exit(main())
  File "./a", line 186, in main
    (proto, cafile), address, port, name, page = _unpack(server)
  File "./a", line 141, in _unpack
    return ((config['protocol'], config.get('cafile', None)), config['address'], config['port'],
TypeError: string indices must be integers, not str

Can you try changing your your /etc/check_mk/apache_status.cfg look like the below? The below config works for me on multiple Checkmk version e.g. 1.2.6p15,1.4,1.5 etc.

servers = [{
 'protocol' : 'https',
 'address'  : '127.0.0.1',
 'port'     : 443 ,
}]

Brilliant Marco! You are my savior!!
Why wasn’t this format published along with the plugin? This info was not available anywhere else It took my head for three weeks and finally Marco unfolded the secret.

Thanks a million Marco!!!