# Consul ingress gateway route to https enabled application

**URL:** <https://discuss.hashicorp.com/t/consul-ingress-gateway-route-to-https-enabled-application/26391>\
**Category:** Consul\
**Created:** [July 5, 2021, 6:58pm UTC](https://discuss.hashicorp.com/t/consul-ingress-gateway-route-to-https-enabled-application/26391 "2021-07-05T18:58:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsbibeksaini](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/itsbibeksaini/32/6818_2.png) [@itsbibeksaini](https://discuss.hashicorp.com/u/itsbibeksaini)\
**Post date:** [July 5, 2021, 6:58pm UTC](https://discuss.hashicorp.com/t/consul-ingress-gateway-route-to-https-enabled-application/26391/1 "2021-07-05T18:58:53Z")

</div>

I am trying to create an ingress gateway which can route the traffic to https enabled applications.

I am using conusl version 1.10.0 here is consul config:

```auto
global:
  name: consul
  datacenter: dc1
  gossipEncryption:
    secretName: "consul-gossip-encryption-key"
    secretKey: "key"
  tls:
    enabled: true
    enableAutoEncrypt: true
    verify: true
  acls:
    manageSystemACLs: true
  metrics:
    enabled: true
    enableGatewayMetrics: true

prometheus:
  enabled: true

ui:
  enabled: true
  service:
    type: 'ClusterIP'
  metrics:
    enabled: true
    provider: "prometheus"
    baseURL: http://prometheus-server

connectInject:
  enabled: true
  transparentProxy:
    defaultEnabled: false
 
controller:
  enabled: true

client:
  enabled: true
  grpc: true

ingressGateways:
  enabled: true
  defaults:
    replicas: 1
  gateways:
    - name: ingress-gateway
      service:
        type: LoadBalancer
        ports:
          - port: 443
            nodePort: null

# Use only one Consul server for local development
server:
  replicas: 1
  bootstrapExpect: 1
  disruptionBudget:
    enabled: true
    maxUnavailable: 0

```

and ingress yaml looks like this:

```auto
apiVersion: consul.hashicorp.com/v1alpha1
kind: IngressGateway
metadata:
  name: ingress-gateway
spec:
  tls:
    enabled: true
  listeners:
    - port: 443
      protocol: http
      services:
        - name: '*'

```

However the traffic routing works perfectly fine when https is not enabled in my application.  
For local development I am using self singed certificates as .pfx file which are volume mounted to the deployment.

I have a micro-service architecture where micro-app 1 wants to connect to micro-app 2 through gRPC. My micro-apps are written in .NET Core 5 and to achieve this I’ve enabled https in micro-apps.

So how I can achieve this through consul IngressGateway resource that it starts routing incoming traffic to my https micro-app.

I always get **no healthy upstream** while trying to hit through localhost

I am stuck here since I am new to consul IngressGateway.

---

<div class="post-metadata">

**Author:** ![kschoche](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/kschoche/32/7847_2.png) [@kschoche](https://discuss.hashicorp.com/u/kschoche)\
**Post date:** [July 6, 2021, 5:22pm UTC](https://discuss.hashicorp.com/t/consul-ingress-gateway-route-to-https-enabled-application/26391/2 "2021-07-06T17:22:55Z")

</div>

Hi @itsbibeksaini! I’m sorry this is not working for you. One thing that I noticed in your steps to reproduce that you missed was adding an intention since ACLs are enabled. Here is a guide for ingress gateways and some information on intentions, also you may have to add servicedefaults which is referenced just above this link. Let me know if you’re able to get this up and running, cheers!

> **[Consul by HashiCorp](https://www.consul.io/docs/k8s/connect/ingress-gateways#defining-an-intention)**
>
> Configuring Ingress Gateways on Kubernetes

---

<div class="post-metadata">

**Author:** ![itsbibeksaini](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/itsbibeksaini/32/6818_2.png) [@itsbibeksaini](https://discuss.hashicorp.com/u/itsbibeksaini)\
**Post date:** [July 7, 2021, 7:08am UTC](https://discuss.hashicorp.com/t/consul-ingress-gateway-route-to-https-enabled-application/26391/3 "2021-07-07T07:08:09Z")

</div>

Hi @kschoche

Yes I’ve configured ServiceIntentions and ServiceDefaults as well. Sorry I didn’t posted complete configuration. So here are my rest of config:

```auto
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceIntentions
metadata:
  name: app1
spec:
  destination:
    name: app1
  sources:
    - name: ingress-gateway
      action: allow

```

```auto
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceDefaults
metadata:
  name: app1
spec:
  protocol: http

```

```auto
apiVersion: v1
kind: ServiceAccount
metadata:
  name: app1

```

```auto
apiVersion : apps/v1
kind: Deployment
metadata:
  name: app1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app1
  template:
    metadata:
      labels:
        app: app1
      annotations:
        "consul.hashicorp.com/connect-inject": "true"
        "consul.hashicorp.com/service-name": "app1"
    spec:
      containers:
        - name: app1
          image: app1:v1
          env:
            - name: "ASPNETCORE_URLS"
              value: "http://[*]:8080"
          ports:
          - containerPort: 8080
            protocol: TCP

```

```auto
apiVersion: v1
kind: Service
metadata:
    name: app1
spec:
    type: ClusterIP
    ports:
    - port: 8080
      targetPort: 8080
      protocol: TCP
    selector:
        app: app1

```

In similar way I’ve bunch of apps in Microservices Architecture and I am using consul’s service discovery and Ingress gateway.

 ![Screenshot 2021-07-07 at 12.23.33 PM](https://global.discourse-cdn.com/hashicorp/original/3X/c/b/cb1c4e9e9a45a6a37bfe7b9eb4cb6d3cad458b91.png)

As you can see in diagram all micro apps in cluster are running on **HTTP** and while sending request I am adding Host to headers. This works perfectly fine and all traffic is being routed to concerned service.

However, if I run these micro apps on **HTTPS** and its deployment is as below:

```auto
apiVersion : apps/v1
kind: Deployment
metadata:
  name: app1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app1
  template:
    metadata:
      labels:
        app: app1
      annotations:
        "consul.hashicorp.com/connect-inject": "true"
        "consul.hashicorp.com/service-name": "app1"
    spec:
      containers:
        - name: app1
          image: app1:v1
          env:
            - name: "ASPNETCORE_URLS"
              value: "https://[*]:8080"
            - name: "ASPNETCORE_Kestrel __Certificates__ Default__Password"
              value: "testPassword123@"
            - name: "ASPNETCORE_Kestrel __Certificates__ Default__Path"
              value: "secret/appSecret.pfx"
          ports:
          - containerPort: 8080
            protocol: TCP
          volumeMounts:
          - mountPath: /app/secret
            name: app-secret
      volumes:
        - name: app-secret
          secret:
            secretName: self-signed-generic-secret

```

k8s secret contains pix certificate which are used by .NET Core app to run on HTTPS  
so now all the micro apps use this certificate and are running on HTTPS:

 ![Screenshot 2021-07-07 at 12.35.27 PM](https://global.discourse-cdn.com/hashicorp/original/3X/4/c/4c9e5006fe80eef5be131ccefb07a0f23874e1b2.png)

so here comes when all the redirection stops and I get this message:

 ![Screenshot 2021-07-06 at 8.47.20 PM](https://global.discourse-cdn.com/hashicorp/original/3X/b/3/b35c2e061cac2394eb7ab6801c3f4463e40e1b25.png)

The reason I need to run apps on **HTTPS** is these micro apps make use of gRPC for internal communication and .NET Core requires TLS secured channel for that  
so that’s how my desired communication looks like:

 ![Screenshot 2021-07-07 at 12.45.13 PM](https://global.discourse-cdn.com/hashicorp/original/3X/9/d/9df4668fae5fc075d4fb710023df5e944d8ec803.png)

---

<div class="post-metadata">

**Author:** ![saltxwater](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/saltxwater/32/17788_2.png) [@saltxwater](https://discuss.hashicorp.com/u/saltxwater)\
**Post date:** [July 8, 2021, 11:16am UTC](https://discuss.hashicorp.com/t/consul-ingress-gateway-route-to-https-enabled-application/26391/4 "2021-07-08T11:16:46Z")

</div>

Hi @itsbibeksaini , just chipping in here as I ran into the same issue yesterday and was watching this thread but have found a solution which works for me:  
If you set your grpc channel credentials to be insecure (no tls), and thus don’t provide call credentials then grpc works fine. You can then set up an interceptor on the client to add the required headers to the request metadata (for us, this is a JWT auth header). Alternatively, you can pass this metadata through with each request (I didn’t think this worked at first but turns out grpc lower cases the header keys).

One caveat with this approach is that I don’t think the web host (in our case Kestrel) can differentiate between http1.1 and http2 requests without tls, so I think you’ll need to configure your grpc port to explicitly listen for http2 requests and use a different port for any standard http requests. These should both be picked up and handled nicely by MVC so not a big issue.

I hope this potentially helps your setup.

I would still be interested in support being added for the sidecar proxy to be able to TLS to the service, potentially just by adding a ca\_path to the config (or with an option to skip\_verify on the cert). Just feels like it would be more flexible with what you put behind your proxy this way!

---

<div class="post-metadata">

**Author:** ![lkysow](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/lkysow/32/1105_2.png) [@lkysow](https://discuss.hashicorp.com/u/lkysow)\
**Post date:** [July 8, 2021, 4:15pm UTC](https://discuss.hashicorp.com/t/consul-ingress-gateway-route-to-https-enabled-application/26391/5 "2021-07-08T16:15:15Z")

</div>

Hi, yeah like @saltxwater said we don’t support routing from the app’s sidecar envoy proxy to the app over TLS. This is because Connect already encrypts the traffic between the services when the request goes through each proxy.

---

<div class="post-metadata">

**Author:** ![itsbibeksaini](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/itsbibeksaini/32/6818_2.png) [@itsbibeksaini](https://discuss.hashicorp.com/u/itsbibeksaini)\
**Post date:** [July 9, 2021, 6:37pm UTC](https://discuss.hashicorp.com/t/consul-ingress-gateway-route-to-https-enabled-application/26391/6 "2021-07-09T18:37:50Z")

</div>

Thanks @saltxwater I’ve tried setting up that and when I run my apps on localhost everything works fine on http2 port however when I take this configuration to Kubernetes I always get the server didn’t completed the http2 handshake

 ![Screenshot 2021-07-09 at 11.05.13 PM](https://global.discourse-cdn.com/hashicorp/original/3X/4/8/4822321e7f0900e8aa604454c4bb4dc73ef0623f.png)

and here is code snippet where I’ve configured http2 port:  
 ![Screenshot 2021-07-10 at 12.07.16 AM](https://global.discourse-cdn.com/hashicorp/original/3X/1/8/18e7941846279e9fede62f3c84e39975cd7b97a5.png)

and gRPC channel:  
 ![Screenshot 2021-07-10 at 8.20.17 PM](https://global.discourse-cdn.com/hashicorp/original/3X/8/7/87ad0de576353da82b4b796d98398c91fd6574a5.png)

where app1 is name of Kubernetes service.

---

<div class="post-metadata">

**Author:** ![saltxwater](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/saltxwater/32/17788_2.png) [@saltxwater](https://discuss.hashicorp.com/u/saltxwater)\
**Post date:** [July 12, 2021, 11:07am UTC](https://discuss.hashicorp.com/t/consul-ingress-gateway-route-to-https-enabled-application/26391/7 "2021-07-12T11:07:29Z")

</div>

Hi @itsbibeksaini , I was able to recreate your error about the http2 handshake, and fixed it by setting the consul connect protocol to “grpc” on the server proxy.

> **[Consul by HashiCorp](https://www.consul.io/docs/connect/proxies/envoy#protocol)**
>
> Consul Connect has first-class support for configuring Envoy proxy.

---

<div class="post-metadata">

**Author:** ![itsbibeksaini](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/itsbibeksaini/32/6818_2.png) [@itsbibeksaini](https://discuss.hashicorp.com/u/itsbibeksaini)\
**Post date:** [July 22, 2021, 6:18pm UTC](https://discuss.hashicorp.com/t/consul-ingress-gateway-route-to-https-enabled-application/26391/8 "2021-07-22T18:18:48Z")

</div>

Finally I made it working 🥳  
I am posting my solution here and it might help someone 🙂

While using [ASP.NET](http://ASP.NET), HTTP/2 gRPC won’t work with envoy proxy.  
To make it work I’ve made use of gRPC-web and gRPC-web client  
 ![Screenshot 2021-07-22 at 11.42.18 PM](https://global.discourse-cdn.com/hashicorp/original/3X/5/a/5af8b7b90bfb0aa83372a3d564378e6e7e26878b.png)

As given in image assume browser is your internal gRPC client which will make request using HTTP/2 but envoy will not convert HTTP request to HTTP/2 for gRPC server.  
And to do this conversion from HTTP to HTTP/2 gRPC web comes to play.

For more information regarding the implementation please follow the official Microsoft document on this:

> **[Use gRPC in browser apps](https://docs.microsoft.com/en-us/aspnet/core/grpc/browser?view=aspnetcore-5.0)**
>
> Learn how to configure gRPC services on ASP.NET Core to be callable from browser apps using gRPC-Web.
