nginx - Nginx 反向代理不在自定义位置传递标头值
问题描述
这是我nginx.conf
在 docker 机器中的文件的反向代理部分:
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();
解决方案
underscores_in_headers on;
将允许带下划线的标题!
推荐阅读
- c - 如何制作高效的循环链表?
- sql - 如何解决 Oracle Apex 中的“无法使用 DISTINCT、GROUP BY 等从视图中选择 FOR UPDATE”错误?
- assembly - 需要帮助了解如何处理系统调用(int 0x80 等)
- ios - 核心文本字体管理器无法在特定范围内注册字体并抛出未记录的错误代码 -2
- c++ - 无法插入到标准映射
- java - 您可以根据计算中的单行 if 语句进行加法或减法吗?
- mysql - 嵌套子查询,SQL
- r - Färe-Primont 指数和 Lowe 指数之间的差异
- python - 为什么 score 方法需要重塑参数而 r2_score 方法不需要?
- python - 程序通过单独创建文件夹来分隔音频,视频并保存它们但是当我再次运行该文件夹已经存在时它会出错