gpt4 book ai didi

nginx - 如何将nginx设置为反向代理(堡垒);我有 "400Bad Request: too many Host headers"

转载 作者:行者123 更新时间:2023-12-04 01:53:28 30 4
gpt4 key购买 nike

我尝试设置 nginx 来验证传入的 https 请求并将它们传递到同一 Intranet (LAN) 中不同主机上的服务器。我从不同的来源得到了以下 conf 文件:

    proxy_redirect              off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwared-For proxy_add_x_forwarded_for;

upstream syncthing_gui
{
server 10.0.0.129:8329;
}

server {
listen 443 ssl;
server_name geras.duckdns.org;

ssl on;
ssl_certificate /etc/letsencrypt/live/geras.duckdns.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/geras.duckdns.org/privkey.pem;

auth_basic "Username and Password required (syncthing)";
auth_basic_user_file /etc/nginx/.htpasswd;

location /sync {

error_log /var/log/nginx/error.log info;
access_log /var/log/access.log;
proxy_pass http://syncthing_gui;
}

}

但我收到错误 400 Bad Request: too many Host headers .我需要改变什么?

最佳答案

此消息不是来自 nginx,而是来自 Golang (Syncthing 是用 Go 编写的)。乍一看,我将此错误解释为发送到 nginx 的 header 过多或过大。但它真正的意思是有太多Host: abc.example.com标题。

在您的配置中,您有
proxy_set_header Host $http_host;
我敢打赌,在其他一些配置文件中,您有重复或类似的行,这会导致 nginx 向服务器发送两个 HTTP Host:标题。大多数软件并不关心这一点,但 Go 的标准 HTTP 服务器会检查这一点并使用 拒绝请求。 400 .

关于nginx - 如何将nginx设置为反向代理(堡垒);我有 "400Bad Request: too many Host headers",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38146781/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com