Giter Club home page Giter Club logo

gke-go-mmproxy's Introduction

gke-go-mmproxy

go-mmproxy is a standalone application that unwraps HAProxy's PROXY protocol (also adopted by other projects such as NGINX) so that the network connection to the end server comes from client's - instead of proxy server's - IP address and port number.

go-mmproxy is deployed on the virtual machine by default. This project deploys go-mmproxy on Google Cloud GKE, so that the Pod deployed behind the TCP Proxy LB can get the real IP of the client.

Deployment architecture

image

Deploy sample nginx with go-mmproxy

kubectl apply -f nginx.yaml

Deploy NEG

kubectl apply -f nginx-neg.yaml

Deploy TCP Proxy LB with Proxy Protocol

gcloud compute health-checks create tcp my-tcp-health-check --port 8080

gcloud compute backend-services create my-tcp-lb \
    --global-health-checks \
    --global \
    --protocol TCP \
    --health-checks my-tcp-health-check \
    --port-name tcp8080

gcloud compute backend-services add-backend my-tcp-lb \
    --global \
    --network-endpoint-group=my-nginx-neg \
    --network-endpoint-group-zone=us-central1-a \
    --balancing-mode CONNECTION \
    --max-connections 100    

gcloud compute target-tcp-proxies create my-tcp-lb-target-proxy \
    --backend-service my-tcp-lb \
    --proxy-header PROXY_V1

gcloud compute forwarding-rules create my-tcp-lb-ipv4-forwarding-rule \
    --global \
    --target-tcp-proxy my-tcp-lb-target-proxy \
    --ports 80

Testing

Note: Wait for 5 minutes after the LB is created before starting the test

Send request from external

curl http://34.160.48.200/

replace 34.160.48.200 to your tcp proxy lb ip

Check client ip in nginx access log

image you can see that this ip is the client ip not tcp proxy lb ip.

Clean

gcloud compute forwarding-rules delete my-tcp-lb-ipv4-forwarding-rule --global --quiet
gcloud compute target-tcp-proxies delete my-tcp-lb-target-proxy --global --quiet
gcloud compute backend-services delete my-tcp-lb --global --quiet
gcloud compute health-checks delete my-tcp-health-check --quiet
kubectl delete -f nginx.yaml
kubectl delete -f nginx-neg.yaml

gke-go-mmproxy's People

Contributors

hellof20 avatar

Watchers

 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.