Bug Bounties

NGINX HTTP to HTTPS redirection not working | LetsEncrypt SSL

The site just works fine on https but doesn't respond when using http https://onsitecourse.com -> This works http://onsitecourse.com -> This does not work I have tried a lot of way to bifurcate server blocks for both HTTP and HTTPS, but nothing seems to be working. My current NGINX config is : ``` server { listen 80; listen [::]:80; server_name onsitecourse.com www.onsitecourse.com; return 301 https://www.onsitecourse.com$request_uri; } server { server_name onsitecourse.com www.onsitecourse.com; root /var/www/onsiteacademy/public; index index.php index.html index.htm index.nginx-debian.html; charset utf-8; location / { try_files $uri $uri/ /index.php$is_args$args; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.0-fpm.sock; fastcgi_read_timeout 240; } listen [::]:443 ssl ipv6only=on; # managed by Certbot listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/onsitecourse.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/onsitecourse.com/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.onsitecourse.com) { return 301 https://$host$request_uri; } # managed by Certbot if ($host = onsitecourse.com) { return 301 https://$host$request_uri; } # managed by Certbot } ``` Would really appreciate some assistance here from anyone!