Symfony stunnel bundle
[][2], (*1)
The stunnel bundle allows you to implement HTTPS connectivity in your local development environment through the use
of stunnel., (*2)
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the
following command to download the latest stable version of this bundle:, (*3)
$ composer require --dev torfs-ict/stunnel-bundle
This command requires you to have Composer installed globally, as explained
in the installation chapter
of the Composer documentation., (*4)
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:, (*5)
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new TorfsICT\StunnelBundle\TorfsICTStunnelBundle(),
);
// ...
}
// ...
}
Step 3: Copy your certificate
Copy your certicate chain and private key into the project e.g. app/config/letsencrypt/fullchain.pem
and
app/config/letsencrypt/privkey.pem
., (*6)
Step 4: Configuration
Sample configuration
# app/config/config_dev.yml
torfs_ict_stunnel:
accept_host: dev.domain.com
forward_host: 192.168.1.15
forward_port: 80
fullchain: "%kernel.project_dir%/app/config/letsencrypt/fullchain.pem"
privkey: "%kernel.project_dir%/app/config/letsencrypt/privkey.pem"
Configuration options
-
accept_host
: The domain for which your certificate is made.
-
forward_host
: The IP address or hostname of your webserver.
-
forward_port
: The port used by your webserver (defaults to 80
).
-
fullchain
: The filesystem location of your certificate chain.
-
privkey
: The filesystem location of your certificate private key.
-
nanobox
: Boolean indicating if you want to enable Nanobox integration (defaults to false
).
Nanobox integration
When using Nanobox you can omit the accept_host
and forward_host
as these will be retrieved
from the Nanobox configuration. Do note that only a single host can be used, so if you have multiple DNS aliases
defined only the last one will be used., (*7)
Usage
Hosts setup
Using stunnel requires dev.domain.org
to point to 127.0.0.1
, so make sure to add it to your systems hosts
file if
required., (*8)
Starting stunnel
Simply use the Symfony console component and execute the command to start stunnel. For Windows the stunnel binaries
are included, in Linux you should make sure that stunnel is installed (for Ubuntu sudo apt-get install stunnel4
)., (*9)
php bin/console stunnel
In Windows an icon in the system tray will be visible, in Linux the stunnel process will be started in the background., (*10)
Once stunnel is running you can navigate to https://dev.domain.com and notice that your site
is now secured with your certificate., (*11)
License
This software is published under the MIT License., (*12)