Question: I want to try and configure a Filter in Envoy Proxy to block ingress and egress to the service based on some IP's, hostname, routing table, etc.

I have searched for the documentation and see it's possible. But didn't get any examples, of its usage. 

Can someone point out some example of how It can be done?

* One configuration example is present on this page:
<https://www.envoyproxy.io/docs/envoy/latest/api-v2/config/rbac/v2alpha/rbac.proto>

	+ But this is for a service account, like in Kubernetes.
* The closest to what I want, I can see here in this page:
<https://www.envoyproxy.io/docs/envoy/latest/configuration/network_filters/rbac_filter#statistics>  

	+ Mentioned as, *"The filter supports configuration with either a safe-list (ALLOW) or block-list (DENY) set of policies based on properties of the connection (IPs, ports, SSL subject)."*
	+ But it doesn't show how to do it.

I have figured out something like this:

```
network_filters:
   - name: service-access
     config: 
        rules: 
           action: ALLOW
           policies:
             "service-access":
                 principals:
                    source_ip: 192.168.135.211
                 permissions:
                    - destination_ip: 0.0.0.0
                    - destination_port: 443

```

**But I am not able to apply this network filter. All the configurations give me configuration error.**

Answer: 
```
ionic cordova platform add browser

```

and then

```
ionic cordova run browser

```

I had to run the 2nd command. With the first command, As it didn't build for me after first command. After this, it worked.
Lets change your code slightly:

```
private createDatabase(){
  const conn = this.sqlite.create({
    name: 'data.db',
    location: 'default' // the location field is required
  })
  console.log('i think the db conn is undefined', conn);
  conn.then(() => {
    // etc
  })
}

```

Here, if `conn` is `undefined` then you are trying to call `undefined.then` which makes absolutely no sense. That's why you are getting the error. The real cause is that it is failing to create your db connection. That's a whole different problem. It would be easier if you changed your code as follows:

```
private createDatabase(){
  const conn = this.sqlite.create({
    name: 'data.db',
    location: 'default' // the location field is required
  })
  if (conn == null) throw Error('Failed to create database connection')
  conn.then(() => {
    // etc
  })
}

```

This catching of errors early makes code much easier to debug.