【问题标题】:Nginx reverse proxy doesn't pass header values in custom locationNginx 反向代理不在自定义位置传递标头值
【发布时间】:2021-08-18 21:47:39
【问题描述】:

这是我在 docker 机器内的 nginx.conf 文件的反向代理部分:

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;
}

但是反向代理不会将我的access_token 标头字段传递给嵌套应用程序:

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

【问题讨论】:

    标签: nginx nestjs reverse-proxy


    【解决方案1】:
    underscores_in_headers on;
    

    将允许带下划线的标题!

    【讨论】:

    猜你喜欢
    • 2021-09-10
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    • 2023-03-08
    • 2018-03-06
    • 1970-01-01
    • 2020-12-18
    • 1970-01-01
    相关资源
    最近更新 更多