Passing all Custom Headers to Proxy Pass in Nginx
Jul 16, 2024
Follow these steps
- 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;
}
}