Reputation: 744
I followed the advice here to configure the nginx reverse proxy to allow files larger than the default 1mb. So, my code in
/.platform/nginx/conf.d/prod.conf
looks like this:
http {
client_max_body_size 30M;
}
However, this seems to have no effect, and nginx still registers an error when I try to upload a file larger than 1mb.
I also tried doing this without the http
and braces, as detailed in the accepted answer to this question, like this:
client_max_body_size 30M;
This also had no effect.
I thought it might be necessary to restart nginx after applying the configuration, so I added a file in the .ebextensions directory called 01nginx.config
, which looks like this:
commands:
01_reload_nginx:
command: "sudo service nginx reload"
This also had no effect.
I have seen this question and the above-referenced question, as well as this one. However, they all seem either outdated or non-applicable to an Amazon Linux 2 instance, since none of them mention the .platform
directory from the above-referenced elastic beanstalk documentation. In any case, none of their answers have worked for me thus far. So, what am I missing?
Upvotes: 9
Views: 9113
Reputation: 609
I had the same issue for a few days, and finaly I solved following these steps:
1 Create a file in this route .platform/nginx/nginx.conf
file nginx.conf
events {}
http {
server {
listen 80;
server_name project-jndxpewg.eu-west-2.elasticbeanstalk.com;
client_max_body_size 64M;
include /etc/nginx/fastcgi_params;
# in my case this is the project public folder
root /var/www/html/webroot;
index index.php;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
try_files $uri \$uri /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
}
Upvotes: 0
Reputation: 31
Below worked for me:
~/my-app/
|-- web.jar
|-- Procfile
|-- readme.md
|-- .ebextensions/
| |-- options.config # Option settings
| `-- cloudwatch.config # Other .ebextensions sections, for example files and container commands
`-- .platform/
|-- nginx/ # Proxy configuration
| |-- nginx.conf
| `-- conf.d/
| `-- custom.conf
Upvotes: 3
Reputation: 366
I has a similar issue when moving to Amazon Linux 2.
Simply creating a file at .platform/nginx/conf.d/
called proxy.conf
with the content below was enough for me.
client_max_body_size 50M;
If you go digging around the main config for nginx you'll see how this file is included into the middle of the file so there's no need to have it wrapped with http.
This is similar to adam tropp's answer, but it follows the example given by AWS
Upvotes: 25
Reputation: 744
Ok, after many tries, I was able to solve this like so:
Add a file in the .ebextenstions directory called 01_reverse_proxy.config
(name doesn't matter, just the .config part I think)
In that file, place exactly this:
files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 30M;
commands:
01_reload_nginx:
command: "service nginx reload"
with proper YAML spacing. This solves the problem on a stack including Rails, Puma, and Amazon Linux 2.11.4. This is NOT the way documented in the elastic beanstalk linux platforms documentation.
Upvotes: 1