Secure Microservices Traffic

Written by Ashnik Team

| Mar 10, 2025

3 min read

Secure Microservices Traffic with NGINX Ingress Controller

Securing microservices traffic is critical as distributed architectures become the backbone of modern applications. In 2023, nearly 40% of organizations reported security breaches in their microservices environments due to misconfigured Ingress controllers and inadequate API protections (Source: CNCF Security Survey). NGINX Ingress Controller provides robust security, scalability, and traffic management for Kubernetes-based microservices. In this blog, we’ll explore how NGINX Ingress Controller enhances security, mitigates risks, and optimizes microservices traffic. You’ll learn:

  • Why traditional Ingress solutions fall short in security
  • How to configure TLS, mTLS, and authentication mechanisms
  • Strategies for rate limiting, bot mitigation, and WAF integration
  • Performance tuning techniques to balance security with speed

Let’s dive into actionable strategies to fortify your Kubernetes workloads.

Why Security in Microservices Traffic Matters

Microservices architectures introduce security challenges like:

  • Increased Attack Surface: More services mean more potential entry points.
  • East-West Traffic Security: Internal service-to-service communication is often overlooked.
  • Rate Limiting & Bot Protection: API abuse can degrade performance and expose vulnerabilities.
  • Data Encryption & Authentication: Ensuring secure connections between services is non-negotiable.

With NGINX Ingress Controller, you get a powerful security layer that addresses these challenges while maintaining performance.

Implementing Strong Authentication & TLS Termination

Enforcing TLS for Secure Communication

TLS encryption ensures that data in transit remains secure. To enforce TLS in NGINX Ingress Controller:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: secure-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
tls:
- hosts:
- your-domain.com
secretName: tls-secret
rules:
- host: your-domain.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-service
port:
number: 80
bulb
Quick Tip:
Use Cert-Manager to automate TLS certificate issuance and renewal.

Enforcing Mutual TLS (mTLS) for Zero-Trust Security

mTLS ensures that both clients and services authenticate each other. Configure NGINX to require client certificates:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: mtls-ingress
annotations:
nginx.ingress.kubernetes.io/auth-tls-verify-client: "on"
nginx.ingress.kubernetes.io/auth-tls-secret: "default/ca-secret"
nginx.ingress.kubernetes.io/auth-tls-pass-certificate-to-upstream: "true"
spec:
rules:
- host: your-domain.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-service
port:
number: 80
bulb
Quick Tip:
Integrate with an identity provider (e.g., Keycloak, Okta) for centralized authentication.

Protecting APIs with Rate Limiting & Bot Mitigation

Applying Rate Limiting to Prevent Abuse

Uncontrolled API requests can lead to DoS attacks. NGINX Ingress Controller allows rate limiting per client IP:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: rate-limit-ingress
annotations:
nginx.ingress.kubernetes.io/limit-rps: "10"
nginx.ingress.kubernetes.io/limit-burst: "20"
spec:
rules:
- host: your-domain.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-service
port:
number: 80

Blocking Malicious Bots & Scrapers

Prevent bot traffic from overloading services using bot detection:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: bot-protection
annotations:
nginx.ingress.kubernetes.io/config-snippet: |
if ($http_user_agent ~* "(curl|wget|bot|crawler)") {
return 403;
}
bulb
Quick Tip:
Use NGINX App Protect WAF to block sophisticated threats.

Enhancing Security with Web Application Firewall (WAF)

A Web Application Firewall (WAF) adds an extra layer of security against SQL injection, XSS, and other web attacks.

Enabling NGINX App Protect WAF

NGINX Ingress Controller supports WAF via NGINX App Protect:

apiVersion: appprotect.f5.com/v1beta1
kind: APPolicy
metadata:
name: custom-waf-policy
spec:
policy:
name: custom_policy
template:
name: POLICY_TEMPLATE_NGINX_BASE
applicationLanguage: utf-8
enforcementMode: blocking

FAQs & Troubleshooting NGINX Ingress Security Issues

  1. Why is my TLS termination not working?
    Ensure that your TLS secret is correctly configured and that your backend service is running on HTTP (port 80) instead of HTTPS (port 443). Also, verify that nginx.ingress.kubernetes.io/ssl-redirect: “true” is set in your annotations.
  2. How do I debug rate limiting issues?
    If rate limiting is not working, check the nginx-ingress-controller logs using:

    kubectl logs -n ingress-nginx deploy/nginx-ingress-controller

    Ensure the limit-rps and limit-burst values are correctly configured in your annotations.

  3. How do I troubleshoot mTLS authentication failures?
    Check that both the client and server certificates are valid and signed by the same CA. Use the following command to verify the certificate chain:

    openssl s_client -connect your-domain.com:443 -CAfile ca-cert.pem
  4. How do I test if bot mitigation is working?
    Use a curl command with a known bot user-agent:

    curl -A "Googlebot" https://your-domain.com

    If bot mitigation is correctly set up, the request should be blocked with a 403 Forbidden response.

Why Choose Ashnik for NGINX Security?

Ashnik has been at the forefront of enterprise-grade NGINX solutions, helping businesses secure and optimize their microservices architecture. Our deep expertise in NGINX, Kubernetes, and open-source technologies ensures that you get the best security, scalability, and performance strategies tailored to your needs.

Looking to enhance your NGINX security posture? Partner with Ashnik for expert-led consulting, implementation, and support.


Go to Top