I do my dev work on an ubuntu 16.04 VM
As I work on a number of projects, to make my life easier I use VirtualDocumentRoot and the hosts file to server sites from my home folder using *.dev domains:
In 000-default.conf I have:
<VirtualHost *:80>
VirtualDocumentRoot /home/steve/websites/%-2/%-2/public_html
ServerAlias *.dev
</VirtualHost>
then in hosts I have the various sites I'm working on:
127.0.0.1 somesite.dev
127.0.0.1 another.dev
127.0.0.1 athirdone.dev
127.0.0.1 blog.athirdone.dev
That way, when I add a new project I just need to create the correct folder structure in the websites directory and add a line to hosts, eg if I want to work on a new project somecoolproject.dev, I just add a folder:
/home/steve/websites/somecoolproject/somecoolproject/public_html
and a line in hosts:
127.0.0.1 somecoolproject.dev
And I'm good to go.
Anyway, pretty much everything I work on now runs over https, and many of the projects have code to enforce this, either in the source code or htaccess etc, making it a pain to work on dev copies.
I would like to create a self-signed cert on my dev machine, and ideally in a way that i dont need to generate a new one for every project, so some kind of wildcard *.dev would be great.
But even if I do need to create a new one for each project, I still can't work out how to install it with my setup - everything I find presumes a fixed document and hardcoded servername.
If I understand the requirements correctly, you want to know:
If I understood this correctly, this is certainly doable.
How will it work: SNI - server name indication, a TLS protocol extension, in which, the hostname is passed when establishing the TLS connection, BEFORE HTTP data (like the host header) is available. All the popular web browsers, curl, all of the popular webservers support it.
Steps:
First. Generate the cert:
The key part is:
Common Name (e.g. server FQDN or YOUR name) []:*.dev
Second.
Server configuration:
Enable ssl and restart apache:
You can test this by:
We like bounties since it's a bit long to write the solution for you :) The real answer to your question is how to make it work, while VirtualDocumentRoot is not gonna work in SSL. I suggest to proxify requests from the default SSL virtual host, to the dynamic non-ssl virtual host. This is possible by keeping the host name which is requested.
First, do all the preliminary work : 1/ generate your private key and certificate (a wildcard if you want so), there are many tutorials for this, 2/ in your main httpd.conf you activate the Include for the extra/httpd-ssl.conf
In the httpd-ssl.conf, you need this conf (I tested it successfully) :
I also suggest to customize the Log format, then you see better what is requested. This will help later debugging, and here are some directives to log with the host name which is requested, and you can recognize SSL or non-SSL traffic by the length of the log lines. In the httpd.conf, look for the the place where the LogFormat is defined and add :
in httpd-ssl.conf, you just need this one :
Tell us if it's working as expected. Once working, the next step is probably to disable non-SSL traffic at least from remote. To achieve this, either configure the local firewall to block requests on port 80, or (better) configure the VirtualHost to listen locally only (VirtualHost 127.0.0.1:80 instead of *:80).