Passing all Custom Headers to Proxy Pass in Nginx

tech kamar
Jul 16, 2024

Follow these steps

  1. Inside server block -> use underscores_in_headers on;

2. Inside location block -> use proxy_pass_request_headers on;

Here is one example below. My UI server is hosted at / and backend server is behind /api/

Here is the nginx.conf file snippet

server {
listen 80 ;
server_name localhost;
client_max_body_size 200M;
underscores_in_headers on;
keepalive_timeout 1500;

location ~* /api/ {
proxy_pass http://localhost:8080;
proxy_pass_request_headers on;
}
location / {
proxy_pass http://localhost:5173;
proxy_pass_request_headers on;
}

}

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response