# Apache2 cookbook SSL setup

**URL:** <https://discourse.chef.io/t/apache2-cookbook-ssl-setup/10115>\
**Category:** Chef Infra (archive)\
**Created:** [December 27, 2016, 11:34am UTC](https://discourse.chef.io/t/apache2-cookbook-ssl-setup/10115 "2016-12-27T11:34:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![avc](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@avc](https://discourse.chef.io/u/avc)\
**Post date:** [December 27, 2016, 11:34am UTC](https://discourse.chef.io/t/apache2-cookbook-ssl-setup/10115/1 "2016-12-27T11:34:41Z")

</div>

Hi,

I am trying setup apache2 with SSL using the apache2 cookbook. Though I can setup default fairly easily, I am not getting how to pass on the port 443 to the config.

```
include_recipe 'apache2'
include_recipe 'apache2::mod_ssl'
include_recipe 'apache2::mod_authz_default'
include_recipe 'apache2::mod_authz_host'

node.default['apache']['listen'] = ["*:443"]

web_app 'mytestingsite' do
	template 'web_app.conf.erb'
    server_name node['hostname']
end

```

This is the simple recipe I am trying to create.

Should a separate template has to be created for SSL ?

Thanks and Regards,

A

---

<div class="post-metadata">

**Author:** ![avc](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@avc](https://discourse.chef.io/u/avc)\
**Post date:** [December 27, 2016, 12:29pm UTC](https://discourse.chef.io/t/apache2-cookbook-ssl-setup/10115/2 "2016-12-27T12:29:52Z")

</div>

Hi, I made some progress,

```
include_recipe "apache2"
include_recipe "apache2::mod_ssl"
include_recipe 'apache2::mod_authz_core'
include_recipe 'apache2::mod_authz_host'

node.default['apache']['myport'] = "443"

web_app 'mytestingsite' do
	template 'web_app.conf.erb'
    server_name node['hostname']
    listen_ports node['apache']['myport']
end

```

In the template

`VirtualHost *:<%= node.default['apache']['myport'] %>>`

That did set the port to 443

```
[root@centos3 sites-available]# cat mytestingsite.conf 
<VirtualHost *:443>
  ServerName centos3
  DocumentRoot 

  <Directory >
    Options FollowSymLinks
    AllowOverride None
    Require all granted
  </Directory>

  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>

  <Location /server-status>
    SetHandler server-status

    Require local

  </Location>

```

Is this the right way ?

Regards,

A
