![]() |
|
Guide Redirect HTTP to HTTPS in aaPanel Free Edition (Nginx) - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: aaPanel (https://adminsforum.com/Forum-aapanel) +---- Forum: aaPanel Guides & Tutorials (https://adminsforum.com/Forum-aapanel-guides-tutorials) +----- Forum: aaPanel Domains, DNS & SSL Guides (https://adminsforum.com/Forum-aapanel-domains-dns-ssl-guides) +----- Thread: Guide Redirect HTTP to HTTPS in aaPanel Free Edition (Nginx) (/Thread-guide-redirect-http-to-https-in-aapanel-free-edition-nginx) |
Redirect HTTP to HTTPS in aaPanel Free Edition (Nginx) - DEV - 10-10-2026 Quick answer After installing a valid website certificate, redirect HTTP requests to HTTPS. This aaPanel Free Edition guide uses a custom Nginx rewrite rule that preserves the hostname, path and query string, while keeping the ACME challenge path available for certificate validation. Before you start Confirm both HTTPS hostnames work without certificate warnings. This example is for Nginx, not Apache or OpenLiteSpeed. Back up existing rewrite rules before editing them; retain any application rules below the new redirect block. Install website SSL first. 1. Open the rewrite editor Go to Website, open your site's settings, and choose URL rewrite. Our new lab site had an empty rule file. Do not replace an existing application's rewrite configuration blindly. 2. Add the redirect block Place this block above your application rewrite rules: Code: # AdminsForum tutorial: HTTPS redirect with ACME exception
set $af_https_redirect 0;
if ($scheme = http) {
set $af_https_redirect 1;
}
if ($uri ~ "^/\.well-known/acme-challenge/") {
set $af_https_redirect 0;
}
if ($af_https_redirect = 1) {
return 301 https://$host$request_uri;
}3. Save and test Click Save. If aaPanel reports a configuration error, restore your previous rules rather than leaving an invalid configuration. Our Nginx configuration test passed after saving. Check HTTP and HTTPS separately. Our results were: Code: http://adminslab.com/ -> 301 -> https://adminslab.com/
http://www.adminslab.com/test-path?check=1
-> 301 -> https://www.adminslab.com/test-path?check=1
https://adminslab.com/ -> 200Important limits
Troubleshooting A redirect loop usually means HTTPS is being redirected again or another proxy/application rule conflicts. Restore your saved rules and inspect the complete chain. A certificate warning must be fixed at the certificate level, not hidden with a redirect. Tested: 10 October 2026, aaPanel Free Edition 8.0.6 with Nginx. Original AdminsForum lab screenshot. |