Search code examples
nginxnestjsreverse-proxy

Nginx reverse proxy doesn't pass header values in custom location


This is the reverse-proxy part of my nginx.conf file inside docker machine:

location / {
    try_files $uri @customer_pwa;
}

location /api {
    try_files $uri @rest_api;
}

location @rest_api {
    proxy_http_version 1.1;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header HOST $host;
    proxy_set_header X-NginX-Proxy true;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_cache_bypass $http_upgrade;
    proxy_pass http://api:7000;
}

But the reverse proxy doesn't pass my access_token header field to nest app:

async function bootstrap() {
  const app = await NestFactory.create(AppModule, { cors: true });
  app.setGlobalPrefix('api');
  await app.listen(7000);
}
bootstrap();


Solution

  • underscores_in_headers on;
    

    will allow underscored headers!