Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
Help with SSL for Multiple Domains (Virtual Hosts) LAMP + Cloudflare
I have 5 domains set up as virtual hosts on LAMP.
They work fine for HTTP but I can’t work out how to configure the config files to work for SSL for each domain.
At the moment, each domain has its own virtual host config file.
I’m using cloudflare CDN and my nameservers go via Cloudflare. I also use Cloudflare SSL and have set up a ‘to server’ SSL via cloudflare on one of my domains.
To do this I set that domain’s config file with the 443 channel and this snippet of code (which works great):
Unfortunately, when I go into the config file of another virtual host domain and do the same setup, after uploading a new .pem and .key from Cloudflare, it doesn’t work and SSL URLs to the new domain redirect to the first domain.
I understand this might be something to do with the order of virtual host files and that 443 only works once?
I’m thinking perhaps I should include all my SSL configs for all domains in a single config file rather than all in separate virtual host config files as they are for non-SSL.
This is where I’ve fallen over though. I just can’t find a good example config for this setup.
Can anyone provide me with a working example file of an SSL setup with multiple domains and multiple .pem and .key files (one for each domain) on a single droplet and IP?
If I’m heading down the wrong track, can you give me example code of the right track?
I’m new to this, but learning fast.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×