GitXplorerGitXplorer
c

aspnetcore-reverse-proxies

public
6 stars
1 forks
0 issues

Commits

List of commits on branch main.
Unverified
365eb20271e49cc79310cacf093a4844fc5ed4b2

[WIP] update readme descriptions

ccecilphillip committed 4 years ago
Unverified
70f512c901ad3b4b48d908633b26a04c404425ab

run fabio with consul

ccecilphillip committed 4 years ago
Unverified
c79b40661b67f120600dfa218d0249adc709f977

haproxy dynamic config w/ consul

ccecilphillip committed 4 years ago
Unverified
8464875a2074e3ae17848fa931646458d78c66b1

Use DNS friendly names (no '.')

ccecilphillip committed 4 years ago
Unverified
efd28d0fd06d9de13edc1b105b4df6a0a266a41b

use consul service discovery for prometheus

ccecilphillip committed 4 years ago
Unverified
3b559b9eb3eebeb981e3f6a556da51cbcc37ccd2

add consul setup

ccecilphillip committed 4 years ago

README

The README file for this repository.

ASP.NET, Reverse Proxies, and Load Balancers

Different sample configurations for running ASP.NET Core behind various load balancers and reverse proxies. Relies on docker-compose files to spin up environments bound to port 80 and 443 on the host machine.

Some of these configurations use TLS and expect a demo.pfx file to be available in the containers for the web APIs. You can use the following command to create one on your machiine.

dotnet dev-certs https -ep ${HOME}/.aspnet/https/demo.pfx -p 1111

Configurations

HAProxy - dynamic load balancing config with docker

This setup configures HAProxy to use Docker's DNS to discover the available API endpoints. The configuration for HAProxy is in the haproxy.cfg file. The load balancer binds to port 80 on localhost. The HAProxy web UI is available on port 81 on localhost. The user name and password for the web UI is set in the frontend stats of the haproxy.cfg file.

Versions

  • HAProxy v2.1.4

Configuration Files

  • docker-compose-haproxy.yml
  • haproxy.cfg
  • api/Dockerfile

Commands

scale up
> docker-compose -f docker-compose-haproxy.yml up --build --scale simplecoreapi_service=4

shutdown
> docker-compose -f docker-compose-haproxy.yml down

logs
> docker-compose -f docker-compose-haproxy.yml logs

HAProxy - dynamic load balancing config with consul

This setup configures HAProxy to use Consul's DNS to discover the available API endpoints. The configuration for HAProxy is in the haproxy4consul.cfg file. The load balancer binds to port 80 on localhost. The HAProxy web UI is available on port 81 on localhost. The user name and password for the web UI is set in the frontend stats of the haproxy4consul.cfg file. Consul's web UI is availiable on port 8500 on localhost.

Versions

  • HAProxy v2.1.4
  • Consul v1.7.3

Configuration Files

  • docker-compose-haproxy-consul.yml
  • haproxy4consul.cfg
  • consul.server.json
  • apiinsights/Dockerfile

Commands

scale up
> docker-compose -f docker-compose-haproxy-consul.yml up --build --scale apiinsights=4

shutdown
> docker-compose -f docker-compose-haproxy-consul.yml down

logs
> docker-compose -f docker-compose-haproxy-consul.yml logs

Traefik - dynamic load balancing config with docker

This setup uses Traefik as a load balancer. Traefik's configuration is provided via labels and command options in the Docker compose file. This configuration uses Docker as a provider for backend services. Traefik binds and accepts traffic on both port 80 and 443 on localhost. It also has a web UI available on port 8080.

Versions

  • Traefik v2.2.1

Configuration Files

  • docker-compose-traefik.yml
  • api/Dockerfile

Commands

scale up
> docker-compose -f docker-compose-traefik.yml up --build --scale simplecoreapi_service=4

shutdown
> docker-compose -f docker-compose-traefik.yml down

logs
> docker-compose -f docker-compose-traefik.yml logs

NGINX - Static config between two servers

This setup uses NGINX as a reverse proxy and load balancer. The NGINX discovers available backends staticly via the nginx.conf configuration file. Scaling the service with Docker compose will not make them visible to NGINX. You'll need to update the configuration file for that.

Versions

  • NGINX v1.19.0

Configuration Files

  • docker-compose-nginx-static.yml
  • nginx.conf
  • api/Dockerfile
  • prometheus.yml

Commands

run
> docker-compose -f docker-compose-nginx-static.yml up --build

shutdown
> docker-compose -f docker-compose-nginx-static.yml down

logs
> docker-compose -f docker-compose-nginx-static.yml logs

Fabio - dynamic load balancing config with consul

This setup configures Fabio as a load balancing along with consul as the source for dynamically providing backend endpoints. The fabio configuration is provided via environment variables in the Docker compose file. Fabio listens for incoming traffic on port 80 on localhost. Also, Fabio's web ui is available on port 9998 on localhost. Consul's web UI is availiable on port 8500 on localhost.

Versions

  • Fabio 1.5.13

Configuration Files

  • docker-compose-fabio-consul.yml
  • consul.server.json
  • apiinsights/Dockerfile

Commands

run
> docker-compose -f docker-compose-fabio-consul.yml up --build

shutdown
> docker-compose -f docker-compose-fabio-consul.yml down

logs
> docker-compose -f docker-compose-fabio-consul.yml logs

TODO

  • Consul Connect
  • Envoy
  • COREDNS