Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Needs a https redirect feature #467

Closed
ibuildthecloud opened this issue Sep 18, 2019 · 4 comments
Closed

Needs a https redirect feature #467

ibuildthecloud opened this issue Sep 18, 2019 · 4 comments
Milestone

Comments

@ibuildthecloud
Copy link
Contributor

Need to be able to redirect from http to https easily to force specific services/path to https only.

@davidnuzik davidnuzik added this to the Backlog milestone Sep 26, 2019
@lucidprogrammer
Copy link
Contributor

Say you created a service like this,

rio run --name sample -p 80:80 nginx:alpine

rio ps
NAME      IMAGE          ENDPOINT                                     PORTS     SCALE     WEIGHT    CREATED          DETAIL
sample    nginx:alpine   https://sample-v0-default.somewhere.on-rio.io   80        1         100%      16 seconds ago  

Check the virtualservices you got

kubectl get vs
NAME                                 AGE
sample                               110s
sample-tls-somewhere.on-rio.io-tls      110s
sample-v0                            110s
sample-v0-tls-somewhere.on-rio.io-tls   110s

Ok, now we need every request coming on the version of your choosing to go to https.

kubectl edit vs sample-v0

Add the following snippet, under the routes.


- matcher:
        prefix: /
      redirectAction:
        httpsRedirect: true
      routePlugins: {}

Once applied, your spec part of the virtualservice will look something like this

spec:
  virtualHost:
    domains:
    - sample-v0-default.somewhere.on-rio.io
    routes:
    - matcher:
        prefix: /
      redirectAction:
        httpsRedirect: true
      routePlugins: {}
    - matcher:
        prefix: /
      routeAction:
        single:
          kube:
            port: 80
            ref:
              name: sample-v0
              namespace: default

@StrongMonkey
Copy link
Contributor

We are going to add this in router.

To add a router with HTTPS redirect, run

rio router add --https-redirect work to sample_service

Then check endpoints of router, access http endpoint will give you redirect link to https

$ curl -i http://xxx.on-rio-io          
HTTP/1.1 301 Moved Permanently
location: https://xxx.on-rio-io 
date: Tue, 17 Dec 2019 22:46:04 GMT
server: envoy
content-length: 0

To add https redirect to your publicdomain, then register public domain to this router

rio route register foo.bar router/work

@lucidprogrammer
Copy link
Contributor

Thank you @StrongMonkey

@rancher-max
Copy link
Contributor

Validated above is working. Small correction to the domain register command: rio domain register foo.bar router/work

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants