How to modify the nginx.conf file during AWS Elastic Beanstalk deployment

I have developed a Django application and deployed it in an Elastic Beanstalk environment (with nginx as proxy server).

The Linux platform should be the first version because if I run the command: cat /etc/os-release in the terminal of the EC2 instance managed by EB I get these information:

Also I double confirm that it’s Linux 1 and NOT Linux 2 by going to the EC2 console:

Now, after having clarified which Linux platform I’m using in the EC2 instance, let’s go ahead with the problem.

When I access the EC2 instance and I go the file etc/nginx/nginx.conf, what I see is this:

Now, what I want to do is to increase the timeout settings under the “server” section of the nginx.conf file.
I also would like to increase the client_max_body_size somehow.

I read from some documentation online the I have to create a .ebextensions folder in the root of my Django project with inside some .config files and also a buildspec.yml file in the root folder of the project.

So this is where I have located my files:

my_project
  |- .ebextensions
  |  |- django.config
  |  |- instances.config
  |  |- nginx.config
  |- buildspec.yml
  |- manage.py
  |...

Here the content of each file:

django.config:

container_commands:
  01_makemigrations:
    command: "source /var/app/venv/*/bin/activate && python3 manage.py makemigrations --noinput"
    leader_only: true
  02_migrate:
    command: "source /var/app/venv/*/bin/activate && python3 manage.py migrate --noinput"
    leader_only: true
  03_collectstatic:
    command: "source /var/app/venv/*/bin/activate && python3 manage.py collectstatic --noinput"
    leader_only: true

instances.config:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: "my_project.wsgi:application" 
  aws:elbv2:listener:443:  
    ListenerEnabled: 'true'  
    Protocol: HTTPS  
    SSLCertificateArns: arn:aws:acm:<region>:<user_id>:certificate/<certificate_id>
  aws:elasticbeanstalk:environment:proxy:staticfiles:  
    /static: staticfiles 
  aws:elbv2:loadbalancer:
    IdleTimeout: 900

nginx.config:

 files:
   "/etc/nginx/conf.d/nginx.custom.conf":
       mode: "644"
       owner: "root"
       group: "root"
       content: |
         client_header_timeout   900;
         client_body_timeout     900;
         send_timeout            900;
         proxy_connect_timeout   900;
         proxy_read_timeout      900;
         proxy_send_timeout      900;
         client_max_body_size    500M;

 container_commands:
   01_restart_nginx:
     command: "sudo service nginx reload"

buildspec.yml:

version: 0.2  
  
phases:  
  install:  
    runtime-versions:  
      python: 3.11  
    commands:  
      - echo Installing dependencies...  
      - pip install -r requirements.txt  
  pre_build:  
    commands:  
      - echo Running migrations...  
      - python manage.py migrate --noinput  
  build:  
    commands:  
      - echo Build completed on `date`  
  
artifacts:  
  files:  
    - '**/*'  

But after deploying the application on the Elastic Beanstalk environment I always see the default nginx configuration.

So my question is, how can I change the configuration of the nginx server during deployment in order to increase the following parameters:

  • client_max_body_size 500M;
  • client_header_timeout 900;
  • client_body_timeout 900;
  • send_timeout 900;
  • proxy_connect_timeout 900;
  • proxy_read_timeout 900;
  • proxy_send_timeout 900;

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật