gpt4 book ai didi

javascript - 如何修复 nginx 上的 http 414 Request-URI Too Large 错误?

转载 作者:行者123 更新时间:2023-12-05 06:10:05 27 4
gpt4 key购买 nike

我希望所有进入我的网络服务器的流量都重定向到 Nginx 上的 https。但是,当我在 http://www.example.com 访问我的网站时,我收到错误“414 Request-URI Too Large”并且 URL 长得离谱 -- http://www.example.com/http:://www.example.com/http: : - 它持续了一段时间,我假设这是给我这个错误的原因。但是我不知道如何解决这个重定向错误,因为我的 Nginx 配置文件不包含 $request_uri 参数。

这是 Nginx 配置文件:

server {
server_name example.com;
return 301 https://www.example.com;

listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}

server {
root /var/www/html;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;

server_name www.example.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
proxy_pass http://localhost:8080; #whatever port your app runs on
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}


server {
if ($host = www.example.com) {
return 301 https://www.example.com;
}


if ($host = example.com) {
return 301 https://www.example.com;
}
listen 80 default_server;
server_name example.com www.example.com;
return 404;
}

如有任何帮助,我们将不胜感激!

最佳答案

我解决了这个问题:

  1. 打开你的 nginx.conf 文件 /etc/nginx/conf.d/nginx.conf

  2. 在http中加入这段代码

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;

client_max_body_size 24M;
client_body_buffer_size 128k;

client_header_buffer_size 5120k;
large_client_header_buffers 16 5120k;

  1. 使用service nginx reload重新加载您的 nginx

关于javascript - 如何修复 nginx 上的 http 414 Request-URI Too Large 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64545112/

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