nginx does not restart after AWS Elastic Beanstalk update environment

My website in AWS Elastic Beanstalk was running ok after installation in php 8.1 using nginx. However a few days later the website is down due to nginx error after AWS updated the environment of Elastic Beanstalk. The website error looks like:

Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

I have to to ssh into AWS instance and restart nginx manually to make it work using the following shell command:

sudo service nginx restart

I store my nginx.conf in .platform/nginx/nginx.conf. The nginx.conf is as following:

#Elastic Beanstalk Nginx Configuration File

user                    nginx;
error_log               /var/log/nginx/error.log warn;
pid                     /var/run/nginx.pid;
worker_processes        auto;
worker_rlimit_nofile    31486;

events {
    worker_connections  1024;
}

http {
    server_tokens off;
    
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    include       conf.d/*.conf;

    map $http_upgrade $connection_upgrade {
        default     "upgrade";
    }

    server {

        location ^~ /pv/ {
           #  allow 192.168.1.1/24;
           deny all;
           return 404;
        }
     
        listen        80 default_server;
        access_log    /var/log/nginx/access.log main;

        client_header_timeout 60;
        client_body_timeout   60;
        client_max_body_size  50M;
        keepalive_timeout     60;
        gzip                  off;
        gzip_comp_level       4;
        gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        # Include the Elastic Beanstalk generated locations
        include conf.d/elasticbeanstalk/*.conf;

    server_name mywebsitename.com;
    index index.php;
    error_page 404 /index.php;

    location /app/upload_video.php {
         client_max_body_size 2084M;
    }
    
    if ($http_user_agent ~ "Snabcd"){
        rewrite ^/?cup/product/([^/]+)/([^/]+)/([^/]+)/location/([^/]+)/([^/]+)/([^/]+)(?:/(menu-selected)/([^/]+)|)/?$ https://$host/indexapp.php?c1=$1&c2=$2&c3=$3&r2=$4&r3=$5&r4=$6&f_urlseo=1&f_idxt=cpn&$7=$8 last;
        rewrite ^/?cup/product/([^/]+)/([^/]+)/([^/]+)(?:/(menu-selected)/([^/]+)|)/?$ https://$host/indexapp.php?c1=$1&c2=$2&c3=$3&f_urlseo=1&f_idxt=cpn&$4=$5 permanent ;
    }

    if ($http_user_agent !~ "Snabcd"){
        rewrite ^/?cup/product/([^/]+)/([^/]+)/([^/]+)/location/([^/]+)/([^/]+)/([^/]+)(?:/(menu-selected)/([^/]+)|)/?$ https://$host/indexpc.php?c1=$1&c2=$2&c3=$3&r2=$4&r3=$5&r4=$6&f_urlseo=1&f_idxt=cpn&$7=$8 last;
        rewrite ^/?cup/product/([^/]+)/([^/]+)/([^/]+)(?:/(menu-selected)/([^/]+)|)/?$ https://$host/indexpc.php?c1=$1&c2=$2&c3=$3&f_urlseo=1&f_idxt=cpn&$4=$5 
    }

    rewrite ^/?ld/([^/]+).*/?$      https://$host/ad_detail.php?ldasid=$1 permanent; 
  
    rewrite ^/?job/sales/location/([^/]+)/([^/]+)/([^/]+).*/?$   https://$host/users/jobs/job_sales.php?r2=$1&r3=$2&r4=$3 permanent; 

    
  https://$host/ect/gamesrc/javascript/tw/index_all_games.php [L,R=301]
    if ($host ~ "192.168.|172.20.|10.0."){ 
        rewrite ^/?games/?$ https://$host/ect/gamesrc/javascript/tw/index_all_games.php permanent;
    } 
    rewrite ^/?games/?$ https://$host/gamesrc/javascript/tw/index_all_games.php permanent;

  }
}

My config file for AWS EBS inside folder .ebextensions is like this:

packages:
  yum:
    sysstat: []
Resources:
  sslSecurityGroupIngress: 
    Type: AWS::EC2::SecurityGroupIngress
    Properties:
      GroupId: {Ref : AWSEBSecurityGroup}
      IpProtocol: tcp
      ToPort: 443
      FromPort: 443
      CidrIp: 0.0.0.0/0
container_commands:
  01nginxrestart:
    command: "sudo service nginx restart"

What is the issue here? How comes AWS does not restart nginx automatically ?

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