redirect on amazon-linux 2 with nginx

It is my first time setting up my own server to host a basic static website. I am using an Amazon Linux 2 VM with nginx/1.18.0. My website is currently up and my files are stored on the following folder in my VM :

/usr/share/nginx/html/

I tried to modify my NGNIX config file to remove file extensions (.html) but when I made the changes, I could not restart the server.

I modified the conf available at: etc/nginx/ nginx.conf and added the server parameter but it did not work ( at the bottom).

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    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"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

server {
       rewrite ^/(.*)\.html /$1/ permanent;
}

You should edit the already defined server block, not add a new one. The server block you want to edit is located in some file inside conf.d directory.