Doesn't redirect HTTP to HTTPS

We perform Nginx configuration on our instance.
Both addresses are working normally.

http://wiki.mydomain.com/xwiki/ and https://wiki.mydomain.com/xwiki

How do I redirect http to https?

[XWiki Debian 14.10.5]
Operating System: Ubuntu 20.04.2 LTS
Kernel: Linux 5.4.0-144-generic
Architecture: x86-64

To redirect HTTP traffic to HTTPS in Nginx for an XWiki installation, you can open the Nginx configuration file for editing and insert a server block that listens on port 80 and returns a 301 redirect to the HTTPS version of your site. Here’s an example of such a server block

server {
    listen 80 default_server;
    server_name _;
    return 301 https://$host$request_uri;
}

This configuration will catch all HTTP traffic on port 80 and redirect it to the HTTPS version of your site using a permanent 301 redirect1.

you can also try Nginx proxy for ssl issue - Help / Discuss - XWiki Forum