/
Nginx on Sunbird

Nginx on Sunbird

Introduction

  • Nginx is a very popular reverse proxy that can scale well and requires minimum amount of resources

  • On sunbird, we are using as an ingress endpoint. All traffic flows into the cluster via nginx proxy

  • Nginx runs on the Kubernetes cluster

  • We have two nginx service running within the Kubernetes cluster

    • Public facing nginx which serves on the domain name

    • Private facing nginx which is used to reach the kubernetes services from services which are running outside the kubernetes cluster

  • The public facing nginx uses a public load balancer and the private facing nginx uses a internal load balancer

  • The public facing nginx runs as a daemonset and the private facing nginx runs as a deployment on kubernetes

Jenkins Jobs

  • The related jenkins jobs for nginx public and private are listed below

    • Build/Core/Proxy

    • ArtifactUpload/Core/Proxy

    • Deploy/Kubernetes/nginx-public-ingress

    • Deploy/Kubernetes/nginx-private-ingress

Ansible Roles and Helm Charts

SSL Renewal

  • Nginx public ingress uses SSL to serve https traffic. The SSL details is stored in private repo. Below are the variables related to SSL

    • Nginx public ingress uses SSL to serve https traffic. The SSL details is stored in private repo. Below are the variables related to SSL

    • https://github.com/project-sunbird/sunbird-devops/blob/master/private_repo/ansible/inventory/dev/Core/secrets.yml#L37-L47

    • Merge domain site key and certificate are missing in private repo templates as it is not required for adopters (required only if running a state SSO system)

    • Below are the variables that need to be defined for merge domain

    • merge_proxy_server_name: # Example merge.dev.sunbird.org sunbird_subdomain_keycloak_base_url: "{{proto}}://{{merge_proxy_server_name}}/auth" merge_domain_status: true proxymerge_site_key: |+ -----BEGIN PRIVATE KEY----- proxymerge_site_crt: |+ -----BEGIN CERTIFICATE-----
    • Merge domain workflow is used to to merge a state account and a personal account into one

    • For more information on the merge domain workflow, reach out to the Sunbird-Ed community

  • SSL can be renewed in two ways - Manual and Automated

  • Manual SSL procurement

    • You can purchase an SSL manually and update the certificate and key in private repo and deploy the below jenkins job to update the kubernetes secrets

    • Deploy/Kubernetes/BootstrapMinimal

    • After this, restart the nginx daemonset (it will auto restart, in case it doesn’t, please restart manually)

    • SSL procurement is a standard process and can be procured from many poplar sites such as https://www.namecheap.com/ and https://letsencrypt.org/

  • Automated SSL procurement

Nginx Public and Private Location Blocks

Nginx Build Process

Nginx Public Prometheus Metrics and Dashboards

Nginx Caching

Nginx Mirroring

  • We can use nginx mirroring feature in case we want to monitor what request headers, payload etc are being sent by a client

  • Nginx mirror block is defined here - https://github.com/project-sunbird/sunbird-devops/blob/master/kubernetes/helm_charts/core/nginx-public-ingress/values.j2#L1217-L1236

  • For details on how mirroring works, refer this docs - https://nginx.org/en/docs/http/ngx_http_mirror_module.html

  • Usually we will deploy an echo service as the backend for the mirroring block

  • The echo service will dump all the data such as headers, payload etc on the stdout. These can be then analysed using Graylog as these logs also will be pushed to the log stack

  • Mirroring should be enabled with utmost care as this will cause the below

    • Access and Bearer tokens will also be displayed in stdout logs. These need to be masked before ingesting into Log ES using Graylog pipelines or it should be disabled from emitting in the echo service itself. If someone gets hold onto these tokens, they will be able to spoof as that user

    • There would be too much data from the echo service stdout logs. This will cause huge load on the graylog and Log ES cluster in terms of CPU and disk. Based on the load, the clusters may need to be scaled up

Nginx GeoIP

Nginx Private

Related content

Additional variables for Core service only
Additional variables for Core service only
More like this
Keycloak on Sunbird
Keycloak on Sunbird
More like this
Ansible Variables
Ansible Variables
More like this
Updating Variables
Updating Variables
More like this
Additional variables to run Core services only
Additional variables to run Core services only
More like this
Load balancer Setup
Load balancer Setup
More like this