By farouk
I have load balancer that balance traffic on droplets which are running using kubernates and I want add header while settings don’t contain anything about header.There are only Forwarding rules, Algorithm, SSL …etc.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
Because DigitalOcean Load Balancers are network load balancers, not application load balancers, they do not support directing traffic to specific backends based on URLs, cookies, HTTP headers, etc.
The Load Balancer feature set primarily focuses on distributing incoming network traffic across multiple Droplets to ensure your applications remain available and responsive.
However, there’s a workaround that you could use for this limitation. You can use a reverse proxy (like Nginx or HAProxy) installed on your Droplets to add or change HTTP headers as necessary.
Here’s a simple example of how to add a header using Nginx:
Install Nginx on your Droplets.
Edit your Nginx configuration file (commonly found at /etc/nginx/nginx.conf or /etc/nginx/sites-available/default).
In the location block where you want to add the header, add the add_header directive. For example, to add a header named X-My-Header with the value My Value, you would add:
location / {
add_header X-My-Header "My Value";
# ...
}
Save your changes and exit the text editor.
Test your configuration file to make sure there are no syntax errors:
sudo nginx -t
sudo systemctl reload nginx
Keep in mind that the add_header directive will not add a header to proxied requests, it adds headers to the response that Nginx sends back to the client.
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.