I finally figured out how to forward all requests to https and wanted to share it. First of all, config.php is located in the flarum folder in the form "url: https://domain.com". Digitalocean is installed SSL with "Certbot" on LEMP server. My Nginx configuration file is as follows.
http://sorucevap.site --> https://sorucevap.site
http://www.sorucevap.site --> https://sorucevap.site
https://www.sorucevap.site --> https://sorucevap.site
server {
listen 80;
listen [::]:80;
root /var/www/flarum/public;
index index.php index.html index.htm;
server_name sorucevap.site www.sorucevap.site;
location = /sitemap.xml { try_files $uri $uri/ /index.php?$query_string; }
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
include /var/www/flarum/.nginx.conf;
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
if ($host = 'www.sorucevap.site' ) {
rewrite ^/(.*)$ https://sorucevap.site/$1 permanent;
}
ssl_certificate /etc/letsencrypt/live/sorucevap.site/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/sorucevap.site/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
#if ($host = www.sorucevap.site) {
# return 301 https://sorucevap.site$request_uri;
#} # managed by Certbot
if ($host = sorucevap.site) {
return 301 https://$host$request_uri;
} # managed by Certbot
# listen 80;
# listen [::]:80;
# server_name sorucevap.site www.sorucevap.site;
# return 404; # managed by Certbot