我有一个问题,nginx似乎忽略(或覆盖)我在AWS Elastic Beanstalk上的Ubuntu Docker容器中的upped client_max_body_size指令.这会阻止用户上传任何大于nginx默认值1MB的文件.
我使用了client_max_body_size 10M; 在http,服务器和位置块无济于事,我仍然看到nginx日志中的"客户端意图发送太大的身体"错误.我已经在AWS EC2 Ubuntu实例上成功使用了这些设置,但由于在Docker容器中使用相同的设置,我遇到了这个问题.我也试过使用这里概述的ebextension 在AWS Elastic Beanstalk上的Nginx conf中增加client_max_body_size
应用程序本身是在Tomcat容器中运行的CFML(Railo).
以下是相关的nginx文件:
完整的未删节文件在这里https://github.com/chapmandu/docker-railo
提前致谢.
2014/12/02 03:02:05 [error] 32116#0: *142 client intended to send too large body: 1290803 bytes, client: 172.31.19.39, server: , request: "POST /listings/35602/images/create HTTP/1.1", host: "staging.svr.com.au", referrer: "http://staging.svr.com.au/listings/35602/images/new"
Run Code Online (Sandbox Code Playgroud)
daemon off;
worker_processes 1;
events {
worker_connections 1024;
}
http {
client_max_body_size 10M;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/sites-enabled/default;
}
Run Code Online (Sandbox Code Playgroud)
server
{
listen 80;
server_name localhost;
client_max_body_size …Run Code Online (Sandbox Code Playgroud) 我有一个非常标准的Spring Boot应用程序(application.properties属性文件位于标准/src/main/resources文件夹中),我将其作为"胖JAR"部署在AWS Elastic Beanstalk上.它工作得很好,但是服务器上的图像上传存在问题.经过一些调查后,似乎需要调整NGINX配置(增加到client_max_body_size可以接受上传的内容10MB),因此我添加了一个带有以下内容的文件.ebextensions夹/src/main/resources(取自此答案): -
files:
"/etc/nginx/conf.d/proxy.conf":
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 20M;
Run Code Online (Sandbox Code Playgroud)
但是,当我运行mvn我的构建时,它不会.ebextensions在根文件夹中创建,我想知道什么是最佳解决方案.我的pom.xml文件很小,目前包含以下内容:
...
<packaging>jar</packaging>
....
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
</dependencies>
</plugin>
Run Code Online (Sandbox Code Playgroud)
提前致谢!
@Lorena当我<resources> ...向我插入XML pom.xml然后启动服务器时,它崩溃了以下内容: -
2017-03-20 21:40:29.504 WARN 10784 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: …Run Code Online (Sandbox Code Playgroud) spring-boot amazon-elastic-beanstalk spring-boot-maven-plugin
我一直在尝试为Java 11 Beanstalk 部署中提供的Nginx服务器增加client_max_body_size,但没有成功。
到目前为止,我已经尝试了AWS Developer Guide方法,在 GitHub 中使用钩子的这种方法,以及我在这个StackOverflow 问题中找到的每个发布的解决方案, 使用 .ebextenstions 中的不同配置。
我遇到的错误因我采用的方法而异,从由于 Nginx 配置中的错误而根本没有部署应用程序到成功部署应用程序但未考虑新的文件大小限制。这些是我尝试过的一些捆绑结构:
捆绑 1
myBundle.zip
--myApplication.jar
--Procfile
--.ebextensions
----nginx
------conf.d
--------proxy.conf
Run Code Online (Sandbox Code Playgroud)
代理配置文件
client_max_body_size 50M;
Run Code Online (Sandbox Code Playgroud)
捆绑 2
myBundle.zip
--myApplication.jar
--Procfile
--.ebextensions
----myconf.config
Run Code Online (Sandbox Code Playgroud)
配置文件
files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 50M;
container_commands:
01_reload_nginx:
command: "sudo service nginx reload"
Run Code Online (Sandbox Code Playgroud)
捆绑 3
myBundle.zip
--myApplication.jar
--Procfile
--.ebextensions
----myhookconfig.config
Run Code Online (Sandbox Code Playgroud)
myhookconfig.config
files:
"/opt/elasticbeanstalk/hooks/appdeploy/enact/12_add_nginx_configuration.sh":
mode: "000755"
owner: …Run Code Online (Sandbox Code Playgroud) 我正在将 Golang 与弹性 Beanstalk 一起使用,我发现我能够上传最大 1 MB 的文件,而那些大于该文件的文件会因错误客户端试图发送太大的主体而失败:1749956 字节,这些字节显然取决于文件大小。我一直在阅读这篇文章在 AWS Elastic Beanstalk 上的 Nginx conf 中增加 client_max_body_size并且我更改了我的代码,在 ebExtensions 下创建了一个文件 01_nginx.config 并将以下内容放入其中,我尝试上传 3 MB 的视频,它仍然给出错误,有什么建议吗?我是新来的
files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 20M;
Run Code Online (Sandbox Code Playgroud) 我已经在 AWS 上部署了 ML 模型。这是一个图像分类器。当我通过 Flask 中的表单向 ML 模型提供以下图像时,它在某些情况下有效,但在其他情况下不起作用。
下面列出了有效图像的链接:https://drive.google.com/file/d/1hbrEa2gNLdqGPJxp5jVxWcXl1wunp5Mc/view ?usp=sharing
下面列出了出现错误的图像的链接: https: //drive.google.com/file/d/1znWTRnTMPft_r_jwpJ0JQuMnnazsUXs-/view ?usp=sharing
上面的两张图片看起来很相似。当我选择文件并将其上传进行分析时,第一个图像大小约为 150kb。然而,当我从 PC 选择并上传该图像进行分析时,该图像大约 10kb 大小却没有。当我尝试使用手机浏览器执行相同操作时,两者均显示错误。
日志中显示的错误是 - [警告]:客户端请求正文缓冲到临时文件中。
nginx amazon-web-services flask amazon-elastic-beanstalk vgg-net
我按照这里的建议配置 nginx 反向代理以允许大于默认 1mb 的文件。所以,我的代码
/.platform/nginx/conf.d/prod.conf
如下所示:
http {
client_max_body_size 30M;
}
Run Code Online (Sandbox Code Playgroud)
但是,这似乎没有效果,当我尝试上传大于 1mb 的文件时,nginx 仍然会注册错误。
我也尝试在没有http大括号的情况下执行此操作,如此问题的已接受答案中所述,如下所示:
client_max_body_size 30M;
Run Code Online (Sandbox Code Playgroud)
这也没有效果。
我认为应用配置后可能需要重新启动nginx,所以我在.ebextensions目录中添加了一个名为 的文件,01nginx.config如下所示:
commands:
01_reload_nginx:
command: "sudo service nginx reload"
Run Code Online (Sandbox Code Playgroud)
这也没有效果。
我已经看到了这个问题和上面提到的问题,以及这个问题。但是,它们似乎都已过时或不适用于 Amazon Linux 2 实例,因为它们都没有提到.platform上述引用的 elastic beanstalk 文档中的目录。无论如何,到目前为止,他们的答案都没有对我有用。那么,我错过了什么?
nginx amazon-web-services amazon-elastic-beanstalk amazon-linux-2
我正在尝试增加可上传到服务器的文件的大小。不过,似乎有一个上限,禁止上传任何超过 1MB 的内容。
我读过很多答案,但没有一个对我有用。
我已经完成了这个问题 Stackoverflow 问题中的所有内容
我也在这里做了一切。 AWS资源
这是我的完整错误
2021/01/15 05:08:35 [error] 24140#0: *150 client intended to send too large body: 2695262 bytes, client: [ip-address-removed], server: , request: "PATCH /user HTTP/1.1", host: "host.domain.com", referrer: "host.domain.com"
Run Code Online (Sandbox Code Playgroud)
我已经在此目录中创建了一个文件(位于我的源代码的根目录下)
.ebextensions/nginx/conf.d/myconf.conf
Run Code Online (Sandbox Code Playgroud)
里面我有
client_max_body_size 40M;
Run Code Online (Sandbox Code Playgroud)
我知道 EB 正在承认它,因为如果出现错误,它就不会部署它。除此之外我不知道该做什么
有人知道这里可能有什么问题吗?
编辑:后端是nodejs v12
编辑:还在 .ebextensions 中的 .conf 文件中尝试过此操作
files:
"/etc/nginx/conf.d/myconf.conf":
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 20M;
Run Code Online (Sandbox Code Playgroud) 我正在尝试通过使用base64进行图像检测从本地上传图像。
在本地主机和邮递员中一切正常。
但是在部署后,我收到了 CROS 错误。
我已经有了 cors 中间件 server.js
const express = require("express");
const cors = require("cors");
const bodyParser = require("body-parser");
const app = express();
app.use(cors());
app.use(bodyParser.json({ limit: "10000kb", extended: true }));
app.use(bodyParser.urlencoded({ limit: "10000kb", extended: true }));
Run Code Online (Sandbox Code Playgroud)
cors 中间件在使用 url 获取图像时工作正常,
但是当我尝试使用base64从本地上传图像时,控制台显示:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Run Code Online (Sandbox Code Playgroud)
这是我尝试过的解决方案:
App.js
const proxyUrl = 'https://cors-anywhere.herokuapp.com/';
fetch(proxyUrl + API_CALL.IMAGE_URL, {
method: 'post',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
inputLink: inputLink,
inputMethod: inputMethod
}), …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用自签名 SSL 为部署在 AWS elastic beanstalk 上的 springboot webserver 后端启用 https。我按照在线教程和指南使用新的 https-instance.config 更改我的 nginx 配置。
files:
/etc/nginx/conf.d/myconf.conf:
mode: "conf"
owner: root
group: root
content: |
# HTTPS server
server {
listen 443;
server_name localhost;
ssl on;
ssl_certificate /etc/pki/tls/certs/server.crt;
ssl_certificate_key /etc/pki/tls/certs/server.key;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
/etc/pki/tls/certs/server.crt:
mode: "000400"
owner: root
group: root
content: |
-----BEGIN CERTIFICATE-----
mycert
-----END CERTIFICATE-----
/etc/pki/tls/certs/server.key:
mode: "000400" …Run Code Online (Sandbox Code Playgroud) ssl nginx amazon-web-services spring-boot amazon-elastic-beanstalk
我正在尝试将图像从客户端上传到服务器进行处理,然后上传到 S3 AWS 存储桶。它适用于本地服务器,但不适用于实时服务器。
XMLHttpRequest cannot load https://api.parthenon-click.com/img_upload/cover. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.parthenon-click.com' is therefore not allowed access. The response had HTTP status code 413.
Run Code Online (Sandbox Code Playgroud)
我使用 ElasticBeanstalk PHP v5.4 作为客户端服务器,Node v7.0 使用 Express v4 服务器作为后端。客户端是简单的 html/css/jQuery。我从用户库中抓取一张照片并使用以下命令将其传递给后端:
$.ajax({
url: api_url,
type: 'POST',
data: form,
processData: false,
contentType: false,
success: function(data){
console.log('upload successful!');
},
error: function(err){
console.log(err);
}
});
Run Code Online (Sandbox Code Playgroud)
只要文件小于 1mb,这就会起作用并保存图像。虽然我仍然收到 504 HTTP 错误。只要我运行本地服务器,无论文件大小如何,它都可以工作。
于是,我就正在增加body-parser,htaccess和multer限制:
身体解析器:
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({ …Run Code Online (Sandbox Code Playgroud) .htaccess node.js express amazon-elastic-beanstalk body-parser
我有一个 Node 10 应用程序在 Elastic Beanstalk 上运行,当请求负载大于 ~1MB 时,它会抛出 413 错误。
<html>
<head>
<title>413 Request Entity Too Large</title>
</head>
<body>
<center>
<h1>413 Request Entity Too Large</h1>
</center>
<hr>
<center>nginx/1.16.1</center>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
该请求根本没有击中我的应用程序;它被 nginx 拒绝了。
我曾尝试根据此答案配置 AWS 以增加允许的请求正文的大小,但无济于事。
我试过添加一个.ebextensions/01_files.config包含内容的文件:
files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 20M;
Run Code Online (Sandbox Code Playgroud)
那不起作用,所以我尝试将文件直接添加到.ebextensions/nginx/conf.d/proxy.conf:
client_max_body_size 20M;
这也不起作用。然后我通过 SSH 连接到实例并直接添加文件。重新部署后,整个conf.d目录被删除并重新写入,没有这个文件。
如何让 AWS Elastic Beanstalk 在 64 位 Amazon Linux 2/5.1.0 上运行 Node.js 10 以接受 nginx …
nginx amazon-ec2 amazon-web-services node.js amazon-elastic-beanstalk
nginx ×8
node.js ×3
spring-boot ×2
.htaccess ×1
amazon-ec2 ×1
body-parser ×1
docker ×1
express ×1
flask ×1
java ×1
java-11 ×1
javascript ×1
railo ×1
reactjs ×1
ssl ×1
ubuntu ×1
upload ×1
vgg-net ×1