cd /news/developer-tools/the-apache-ssl-line-that-looks-right… · home › topics › developer-tools › article
[ARTICLE · art-147563] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=· neutral

The Apache SSL line that looks right and still won't start

A developer building a free Nginx and Apache SSL config generator found that Apache 2.4 rejects the common pattern of placing SSLStaplingCache inside a <VirtualHost> block, because mod_ssl allows SSLUseStapling there but restricts SSLStaplingCache to server-level config. The generator also had to replace Nginx's shared:SSL:10m cache syntax with Apache's shmcb path-and-byte-size form, add the missing SSLSessionCache directive, and point ErrorLog at /dev/stderr so startup failures inside Docker test containers were visible.

by read3 min views2 publishedOct 8, 2026

I built a free config generator for Nginx and Apache. Before shipping the SSL part, I ran every output against a real Nginx 1.27 and Apache 2.4 server. Using AI, I built a test sandbox instead of just reading the configs over.

That saved me more than once. The Apache version had two errors, both on the same line, and both looked completely fine on screen.

The goal was simple enough. Take a Let's Encrypt certificate and produce the Apache config for HTTPS with OCSP stapling turned on. Stapling lets your server send the certificate's "still valid" proof along with the handshake, so the visitor's browser doesn't have to go and ask the certificate authority itself.

On Apache, stapling needs two directives:

SSLUseStapling on turns stapling on.SSLStaplingCache tells Apache where to keep the stapled responses. Version 1 put everything inside the site's <VirtualHost *:443> block, the way a lot of snippets online do:

<VirtualHost *:443>
    SSLEngine on
    SSLCertificateFile    /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    SSLUseStapling on
    SSLStaplingCache "shared:SSL:10m"   # two errors on this one line
</VirtualHost>

It reads fine. But it isn't.

Apache didn't start. apachectl configtest stopped with a syntax error on the SSLStaplingCache line, saying the directive is "not allowed here".

The reason is scope. In Apache's mod_ssl, SSLUseStapling is allowed inside a <VirtualHost>, but SSLStaplingCache is server config only. It sets up one cache shared by the whole server, so it must sit in the main config: httpd.conf, or ssl.conf / mods-available/ssl.conf on Debian and Ubuntu. Put it inside any <VirtualHost> and Apache refuses the file.

It's an easy mistake to make, because the two directives belong together, so they naturally end up next to each other in the same block.

After moving the line out of the <VirtualHost>, Apache still rejected it. This time it was the value.

shared:SSL:10m is Nginx syntax, borrowed from Nginx's ssl_session_cache directive. Apache uses its own cache providers, and the common one is shmcb (shared memory, cyclic buffer), written as a path plus a size in bytes:

SSLStaplingCache "shmcb:/tmp/ssl_stapling_cache(32768)"

When you're building something like this, you often write the Nginx and Apache outputs side by side. I was using AI to speed things up, got a bit lazy, and the Nginx habit slipped into the Apache side. A developer who knows Nginx might read shared:SSL:10m and move on. Apache doesn't.

One more lesson came from the sandbox itself. For a while, Apache seemed to just exit with no error at all. My test container had ErrorLog pointing at a file, so when Apache died during startup, the error was written to a log file inside a container that had already stopped.

Pointing ErrorLog at /dev/stderr for testing fixed it immediately, and the real error messages showed up. If you test Apache in Docker, do that first. Save yourself the headache!

While I was in there, the testing also showed that the Apache output was missing SSLSessionCache, which the Nginx side already had. It's the same kind of directive (server config only), and it uses shmcb too.

The fix was to split the output into two clearly labelled parts.

Once, in the main server config (outside any <VirtualHost>):

SSLSessionCache  "shmcb:/tmp/ssl_scache(512000)"
SSLStaplingCache "shmcb:/tmp/ssl_stapling_cache(32768)"

Inside your <VirtualHost *:443> block:

SSLEngine on
SSLCertificateFile    /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLProtocol -all +TLSv1.2 +TLSv1.3
SSLUseStapling on

Test before you reload, so a mistake never takes the site down:

sudo apachectl configtest && sudo systemctl reload apache2   # httpd on RHEL/Alma/Rocky/Fedora

The && means the reload only happens if the test passes.

SSLUseStapling. Only the server knows which context each one is allowed in. If you'd rather skip the trial and error, my ProxyForge SSL generator gives you the Certbot command plus the matching Nginx or Apache config, with the Apache output already split into the two parts above. It's free, needs no signup and runs in your browser. The how-to guide explains where each piece goes.

Have you hit other Apache directives that are only allowed in one context? I'd like to hear about them, since they're exactly the kind of thing worth checking, and maybe adding to my tool.

── more in #developer-tools 4 stories · sorted by recency
── more on @apache 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/the-apache-ssl-line-…] indexed:0 read:3min 2026-10-08 · —