Git Product home page Git Product logo

load-balanced-services's Introduction

Load Balanced Services

Purpose

This project was to prove the TLS communication path between two ASP .net Core docker containers using docker-compose. In addition to TLS communication NGINX load balancers sit in front of each service which fowards all headers through to each service. Each service in turn, accepts the forwarded headers and recognize requests as TLS encrypted and attach HSTS headers to the response payload.

Setup

Postman
  1. Install Certificate
    • Open Postman and navigate to Gear Icon -> Settings -> Certificates tab -> CA Certificates Click on the browse button
    • Navigate to Certificates -> ca -> intermediate -> certs -> Select ca-chain.crt

Otherwise postman will get: SSL Error: Unable to verify first certificate.. Postman doesnt respect the certificates installed on your machine, it needs to be trusted directly.

Endpoints
  • /api/test
  • /api/httpapicall
  • /api/httpsapicall
Ports
  • Service1 Load balancer
    • http: 8101
    • https: 8102
  • Service1 Direct
    • http: 8103
    • https: 8104
  • Service2 Load balancer
    • http: 8201
    • https: 8202
  • Service2 Direct
    • http: 8203
    • https: 8204
Example Requests & Responses
GET /api/test HTTP/1.1
Host: localhost:8102

Response:
{
    "ServiceMessage": "Hello from service1!",
    "HostName": "fd9a4d6f939f \t fd9a4d6f939f\t 10.1.0.2",
    "RequestMethod": "GET",
    "RequestScheme": "https",
    "RequestUrl": "https://nginx/api/test",
    "RequestPath": "/api/test",
    "RequestHeaders": [
        "Cache-Control: no-cache",
        "Connection: keep-alive",
        "Accept: */*",
        "Accept-Encoding: gzip, deflate, br",
        "Host: nginx",
        "User-Agent: PostmanRuntime/7.26.5",
        "X-Real-IP: 10.1.0.1",
        "X-Original-Proto: http",
        "X-Original-Host: localhost:8102",
        "X-Forwarded-Port: 8102",
        "Postman-Token: e711d2d2-db7f-4370-b5ef-c28bcbe28696",
        "X-Original-For: [::ffff:10.1.0.3]:37430"
    ],
    "RemoteIp": "10.1.0.1"
}

Useful Resources

Code
  • Stack overflow question. The third answer down was a useful extension method to replace the CertificateValidationCallBack. This proved very useful when debugging the reason behind certificate validation failures.

  • Rob Rich presentation and github repo on this topic

Known Bugs

load-balanced-services's People

Contributors

slomangino123 avatar slomangino avatar

Stargazers

Timothy Ian Munnerley 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.