Skip to content
Ercan Ermis
Ercan Ermis

notes for everyone about cloud technology

  • Cloud
    • AWS
    • GCP
  • Container
    • Kubernetes
    • Docker
  • Linux
  • DevOps
  • Privacy Policy
  • Contact
Ercan Ermis

notes for everyone about cloud technology

Prevent nginx from caching DNS for proxy

Ercan, August 22, 2022February 12, 2023

Hello everyone,

If you are using nginx as a proxy and/or reverse proxy, the nginx is caching the DNS information and if you are using AWS Application Load Balancer behind the nginx, and nginx sometimes needs to restart and/or DNS flushing to send a request to the AWS Application Load Balancer because AWS is always giving a CNAME and changing the Load Balancer IP address frequently.

There is no option to flush DNS on nginx, the only option is to restart the nginx and you can’t solve the problems with restart always : ) You can use the nginx config below to fix this DNS Caching problem.

server {
   listen       80;
   server_name  proxy-request.ercanermis.net;

   include /etc/nginx/default.d/*.conf;

   set $proxydestination "backend.ercanermis.com";
   proxy_pass https://$proxydestination;
   proxy_http_version 1.1;
   proxy_set_header Host proxy-request.ercanermis.net;
   proxy_redirect off;
   proxy_cache_bypass 1;
   proxy_no_cache 1;
   resolver 8.8.8.8 valid=5s;
   }
}

If you have any questions, please feel free to comment, thank you!

Share on Social Media
x facebook linkedin reddit
Best DevOps dnsnginxproxyreverse proxy

Post navigation

Previous post
Next post
  • AWS (45)
    • Serverless (4)
  • Best (9)
  • DevOps (16)
  • Docker (10)
  • GCP (3)
  • Kubernetes (3)
  • Linux (13)
  • Uncategorized (6)

Recent Posts

  • Automating AWS CloudWatch Log Group Tagging with Python and Boto3
  • Automating AWS ECR Tagging with Python and Boto3
  • Automating ECR Image Cleanup with Bash
  • Update ECR Repositories with Bash Script
  • Why Automated Tests Are Essential in Your CI/CD Pipeline and Development Flow
  • Streamline Your AWS ECR Management with This Powerful Bash Script
  • Setting up DKIM for Google Workspace (Gmail) using Terraform and AWS Route 53
  • Automate AWS Site-to-Site VPN Monitoring
  • Optimizing Docker Images: Tips for Reducing Image Size and Build Time
  • Monitoring EC2 Disk Space with a Simple Bash Script and Slack Alerts
  • Securing Docker Containers: Best Practices for Container Security
  • Mastering Dockerfile: Writing Efficient, Scalable Container Builds
  • Migrating a Git Repository from GitLab to GitHub with GPG-Signed Commits
  • Accessing AWS Services in Private Subnets Without 0.0.0.0/0
  • Understanding AWS Regions, Availability Zones, and VPCs: A Comprehensive Guide
©2025 Ercan Ermis | WordPress Theme by SuperbThemes