You buy a domain on Namecheap, set up hosting on Hostinger, and toss StackPath in front for caching and DDoS mitigation. If you connect them in the wrong order, your browser will immediately trap you in an infinite redirect loop or an SSL handshake error.
I ran into this exact mess on a client project. StackPath acts as a reverse proxy between your visitors and Hostinger. If your origin certificate, edge certificate, and DNS routing don’t line up across port 443 and Server Name Indication (SNI), the whole setup falls apart. Here is how I wire all three layers together for true end-to-end TLS encryption without breaking production.

The Architecture: Why End-to-End SSL Breaks
Before clicking around in dashboards, look at how the traffic actually flows. A visitor resolves your domain through Namecheap DNS, which points to StackPath’s edge. StackPath terminates that edge TLS connection, checks for a cached asset, and—on a cache miss—fetches it from Hostinger over a second, separate TLS connection.
A lot of bad tutorials suggest enabling “Flexible SSL” or downgrading edge-to-origin traffic to plain HTTP on port 80. Don’t do that. Hostinger runs Nginx/LiteSpeed proxies that automatically bounce HTTP back to HTTPS. When StackPath asks Hostinger for assets on port 80, Hostinger shoots back a 301 Moved Permanently to https://yourdomain.com. StackPath queries its own edge URL again, and your browser crashes with ERR_TOO_MANY_REDIRECTS.
End-to-end SSL means two valid certs must coexist: one on StackPath for visitors, and one on Hostinger for StackPath’s origin pulls. To avoid verification headaches, Hostinger has to be sorted out first.
Step 1: Provision Hostinger and Issue the Origin Certificate
If you repoint your Namecheap DNS to StackPath before generating an SSL cert inside Hostinger hPanel, Hostinger’s Let’s Encrypt bot will fail. The ACME HTTP-01 challenge hits StackPath instead of Hostinger’s local webroot.
Save yourself the trouble: leave Namecheap pointed straight to Hostinger for ten minutes until the cert issues, or do it on Hostinger’s staging domain. In hPanel, go to Websites, hit Manage, and jump to Security > SSL.
Hostinger auto-generates a free Let’s Encrypt or ZeroSSL cert as long as the domain resolves to their shared IP. Verify it’s active in hPanel:
- Status: Active
- Issuer: Let’s Encrypt / Google Trust Services
- Domain coverage:
example.comandwww.example.com
Leave “Force HTTPS” toggled off in hPanel for now. We want to prove StackPath can talk to Hostinger over HTTPS first without Hostinger throwing unsolicited redirects. If you run into mixed content bugs later on, check our guide to fix WordPress mixed content on Hostinger after SSL.
Grab your Hostinger server IP from the sidebar under Hosting > Plan Details. Keep that IPv4 address (something like 195.179.236.42) handy for StackPath.
Step 2: Create the StackPath Site and Origin Configuration
Log in to StackPath. We need to create a CDN site and tell it to pull from Hostinger over HTTPS with SNI enabled.
- Click Create Site and pick CDN.
- Enter your apex domain (e.g.,
example.com). - Under Origin Type, choose IP Address and paste your Hostinger shared IP.
Once StackPath creates the site container, head to CDN > Site Settings > Origin. This is where most people get tripped up.
Set your origin parameters exactly like this:
- Origin Port:
443 - Origin Protocol:
HTTPS Only - Validation: Turn on certificate validation (Hostinger is running a public Let’s Encrypt CA).
- Peer SNI: Turn this ON. This is critical. Hostinger puts hundreds of sites on one shared IP. Without SNI headers matching your domain, Hostinger won’t know which vhost SSL cert to present, and you’ll get an instant
502 Bad Gateway.
Set the origin host header field explicitly to your domain: example.com.
If you’re dealing with dynamic sessions or logged-in cookies, check out our StackPath EdgeRules guide to prevent edge caches from serving stale session data.
Step 3: Issue the Edge SSL Certificate on StackPath
Now we need a certificate on StackPath’s edge so public visitors get a clean padlock. Open the EdgeSSL tab in your StackPath site dashboard.
Click Generate Free Certificate. StackPath issues edge certs through Let’s Encrypt. It will offer either HTTP validation or DNS validation via CNAME/TXT records.
I always use manual DNS verification here to prevent race conditions while switching traffic over. StackPath will give you a CNAME verification target formatted something like this:
Keep that tab open. We will paste that record into Namecheap next.
Step 4: Update Namecheap Advanced DNS Records
Log in to Namecheap, go to your Domain List, and hit Manage on your domain. Check the Nameservers dropdown—make sure it’s set to Namecheap BasicDNS or Namecheap WebDNS, not custom nameservers, or you won’t be able to edit records here.
Click the Advanced DNS tab. We are pointing your root domain and www record to StackPath instead of Hostinger. StackPath gives you either an edge hostname (like c123.stackpathcdn.com) or dedicated Anycast IPs.
Because the DNS spec (RFC 1912) doesn’t allow standard CNAMEs on the root apex (@), you have to choose between an IP address record or an alias. Read our breakdown on A Record vs CNAME for root domains in Namecheap to see how Namecheap handles root aliases.
In Namecheap Advanced DNS, set up these three records:
- Root Domain: Create an
ALIAS RecordorA Recordwith host@pointing to the StackPath edge target or Anycast IP. - Subdomain: Add a
CNAME Recordfor hostwwwpointing to your StackPath CDN hostname (e.g.,site.stackpathdns.com). - SSL Verification: Add the CNAME validation record provided by StackPath EdgeSSL.
Drop the TTL on all records to 1 min (or 5 minutes). When troubleshooting DNS migrations, short TTLs are your best friend.
If you see leftover parking or redirect records from Namecheap, clear them out. You can reference the Namecheap DNS host record documentation if anything looks unfamiliar.
Step 5: Test the TLS Handshake and Routing with Terminal Commands
Don’t test this in a desktop browser. Chrome and Safari cache redirects and DNS aggressively, which completely blinds you to edge behavior. Use your terminal.
First, confirm Namecheap is resolving to StackPath rather than your old Hostinger IP:
Check the DNS resolution with dig:
dig +short example.com
dig +short www.example.comYou should see StackPath Anycast IPs, not the Hostinger origin IP.
Next, test the edge TLS handshake directly against StackPath to verify the certificate:
Inspect the edge TLS handshake with openssl:
openssl s_client -connect example.com:443 -servername example.com &1 | grep -E "(issuer|subject)"Verify that the subject matches your domain and the issuer is Let’s Encrypt or Sectigo. If you see a generic CDN fallback cert, the EdgeSSL provisioning isn’t finished yet.
Now test the HTTP redirect chain with curl:
Query the edge over HTTP to see the redirect:
curl -ILs -o /dev/null -w %{http_code}"n" http://example.comYou want to see a single 301 or 302 bounce over to HTTPS, followed by an immediate 200 OK. If curl loops endlessly, your origin setup is conflicting with StackPath.
Step 6: Fix the Redirect Loop and Hostinger .htaccess Rules
If you do hit ERR_TOO_MANY_REDIRECTS, here is what is happening: StackPath connects to Hostinger, but Hostinger doesn’t realize the original client request was HTTPS. Hostinger fires back a redirect, StackPath re-requests the asset, and you get an infinite bounce.
StackPath passes the X-Forwarded-Proto: https header with every origin request. We just need to tell Hostinger’s Apache/LiteSpeed web server to look for it.
Log in via SSH or open the File Manager in hPanel. Open public_html/.htaccess and add this right at the top, before any WordPress rewrite blocks:
Add reverse proxy SSL detection to .htaccess:
# Ensure HTTPS is recognized behind StackPath reverse proxy
SetEnvIf X-Forwarded-Proto "https" HTTPS=on RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]This tells Apache: if X-Forwarded-Proto says https, set the internal HTTPS flag to on. WordPress sees this flag, realizes the request is already encrypted, and stops sending redirects.
For a deeper dive on handshake requirements and proxy headers, check the MDN TLS reference guide.
Step 7: Lock Down Origin Access to StackPath Edge IPs
Right now, your site routes through StackPath, but your Hostinger server is still sitting exposed on its public IP. Anyone who figures out the IP can bypass your CDN caching, WAF, and DDoS protection entirely.
We need to lock down origin access so only StackPath’s edge IPs can talk to Hostinger. If you run a custom Nginx box or have root VPS access, see our guide on how to restrict origin access to StackPath Origin Shield IPs.
On shared Hostinger plans, you can enforce this in .htaccess by allowing only StackPath ranges (and your own office IP for debugging):
Add IP allowlist rules to .htaccess:
# Restrict direct origin access
Require ip 151.139.128.0/19 Require ip 198.252.110.0/24 Require ip 127.0.0.1
Make sure to pull the latest IP blocks from StackPath’s docs, as edge ranges occasionally change. If an origin cert ever expires or gets corrupted, use the Hostinger SSL installation guide to force a manual reissue.
Frequently Asked Questions
Why does StackPath return a 502 Bad Gateway after pointing my DNS?
A 502 almost always means StackPath couldn’t finish the TLS handshake with Hostinger. Usually, Peer SNI is disabled, or the Origin Host Header doesn’t match the Hostinger vhost domain. Go to Site Settings > Origin in StackPath, turn on Peer SNI, and set the Origin Host Header to your exact domain name.
Can I use a self-signed SSL certificate on Hostinger?
Technically yes, but you would have to tell StackPath to disable certificate validation. Don’t do that. Ignoring validation exposes your origin pulls to man-in-the-middle attacks. Hostinger provides free Let’s Encrypt certificates automatically—just use those.
Do I need to update Namecheap nameservers to Hostinger or StackPath?
No. Keep your nameservers on Namecheap BasicDNS. You only need to touch the A, ALIAS, and CNAME records under Advanced DNS. Changing nameservers delegates your entire DNS zone somewhere else, which adds needless complexity.
What happens when Hostinger renews the origin SSL certificate?
Nothing breaks. As long as StackPath connects over port 443 with SNI enabled, Hostinger’s automated Let’s Encrypt bot will renew behind the scenes. StackPath validates the new certificate dynamically on the next origin pull.
Next Steps
Once your DNS settles and curl returns a clean 200 OK, verify your caching rules so admin dashboards and session cookies don’t get stuck in the CDN cache. If you’re on WordPress, see our walkthrough on how to bypass CDN cache for logged-in WordPress users using StackPath EdgeRules.

