gpt-4-0314· openai
Suzhen/CodeChat
使用nginx转发时,header中的Authorization 没有被转发
- User
使用nginx转发时,header中的Authorization 没有被转发
- Assistant
在 Nginx 配置文件中配置转发时,请确保在 location 块内添加如下内容,以确保 Authorization 头被转发:
proxy_pass http://your-upstream; proxy_set_header Authorization $http_authorization;这样,Nginx 会将请求中的 Authorization 头转发给上游服务器,保持此头部的原始内容。
以下是一个完整的示例,用于将请求转发到名为 your-upstream 的上游服务器:
http { upstream your-upstream { server backend.example.com; } server { listen 80; location / { proxy_pass http://your-upstream; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Authorization $http_authorization; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_cache_bypass $cookie_nocache $arg_nocache$http_pragma$http_authorization; proxy_no_cache $cookie_nocache $arg_nocache $http_pragma$http_authorization; } } }这个配置示例从名为 your-upstream 的上游服务器加速请求,并传递必要的头。其中包括 Authorization 头,会被转发到上游服务器。
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.