Can you help me with this nginx configurtation to get it working with a domain in https?

  dns, docker, networking, nginx, node.js

Setup is :
VPS Server with IP lets say
Domain :
Docker compose with db, backend and frontend

The front end is written in Vue.js

I set up the domain DNS as the following :
A host:* ip: ttl: 300
A host:@ ip: ttl: 300
CNAME alias:www points at: ttl:300
Dockerfile for the frontend

FROM node:latest as build-stage
COPY package*.json ./
RUN npm install
COPY ./ .
RUN npm run build

FROM nginx as production-stage
RUN mkdir /app
COPY --from=build-stage /app/dist /app
COPY nginx.conf /etc/nginx/nginx.conf
COPY ./ssl/certs/ /etc/nginx/ssl/
COPY ./ /etc/nginx/conf.d/

Now the NGINX conf inside the dockerfile:

worker_processes  1;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/;
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;
  keepalive_timeout  65;
  server {
    listen       80;
    server_name  localhost;
    location / {
      root   /app;
      index  index.html;
      try_files $uri $uri/ /index.html;
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
      root   /usr/share/nginx/html;

And looks like this

server {
        listen          80;
        server_name default_server;
        add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
        expires off;
        return  301     https://$server_name$request_uri;
server {
        listen 443 ssl;
        client_max_body_size 32M;
        add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";

        ssl_certificate      /etc/nginx/ssl/fullchain.pem;
        ssl_certificate_key  /etc/nginx/ssl/privkey.pem;

  root "/usr/share/nginx/html";
  index index.html index.htm index.php; 

and in the server I changed etc/hosts with the following line:

How can I get it to work, it’s almost done production ready. Just this conf is blocking me.

Thank you in advance!

Source: Docker Questions