GithubHelp home page GithubHelp logo

gabihodoroaga / simpleredirect Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 3 KB

A basic redirect server written in go that can be used as a backend for GKE Ingress to redirect one domain to another

Dockerfile 1.51% Go 98.49%
http-server http-redirect gke

simpleredirect's Introduction

simpleredirect

A basic redirect server written in go that can be used as a backend for GKE Ingress to redirect one domain to another on GCP.

Features

  • allow redirection of a domain to any url. E.g. test.com => https://example.com/someurl
  • uses /hc to respond to health checks. This is useful for Ingress on GKE for NEGs

Build and run

build

env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/simpleredirect .

create the docker image

docker build -t gabihodoroaga/simpleredirect .

run in docker

docker run --rm -it -p 8080:8080 gabihodoroaga/simpleredirect --redirect=t1.com:https://t2.com:302

deploy using kubernetes

apiVersion: apps/v1
kind: Deployment
metadata:
  name: server-redirect
spec:
  replicas: 1
  selector:
    matchLabels:
      app: server-redirect
  strategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: server-redirect
    spec:
      containers:
      - name: server-redirect
        image: gabihodoroaga/simpleredirect:1.0.2
        args:
        - "-redirect=host.com:https://example.com"
        - "-redirect=test.com:https://example.com/test:302"
        ports:
        - name: http
          containerPort: 8080

test

curl -v -H "Host: t1.com" http://localhost:8080

TODO:

  • add unit tests for redirect function
  • configurable access logs

Is it any good

I hope will be any good for someone else at least to save a half a day to build something similar when you don't have the time. If this is the case then you can give me a star. It will make me smile.

simpleredirect's People

Contributors

gabihodoroaga avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.