Skip to content

Commit f0ca2ed

Browse files
authored
Merge pull request #13 from elan-ev/extra-vhosts
Allow additional vhosts
2 parents 61c1d27 + 7bd6b4d commit f0ca2ed

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,16 @@ If you want to use Let's Encrypt to generate certificates, you can also include
3636
[`elan.opencast_certbot`](https://galaxy.ansible.com/elan/opencast_certbot)
3737
which will automatically generate TLS certificates for you.
3838

39-
4039
You can also add some custom configuration in the file `/etc/nginx/conf.d/extra.conf`.
4140
The file is included after Opencast's main `location` block.
4241
The role will not modify this file if it exists.
4342

43+
Additionally you can define other virtual hosts in `/etc/nginx/sites-enabled/` directory.
44+
They will be loaded as well.
45+
46+
> ℹ️ You may want to disable Nginx default vhost on Debian based systems by removing the
47+
`/etc/nginx/sites-enabled/default` symlink.
48+
4449

4550
Example Playbook
4651
----------------
@@ -72,7 +77,7 @@ The role will _not_ replace an existing certificate so you can safely use a `fil
7277
owner: root
7378
group: root
7479
mode: '0400'
75-
notify: reload nginx
80+
notify: Reload nginx
7681
loop:
7782
- key
7883
- crt

molecule/default/verify.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
tasks:
77
- name: Test that nginx redirects to https
88
ansible.builtin.uri:
9-
url: http://127.0.0.1/
9+
url: http://{{ inventory_hostname }}/
1010
follow_redirects: none
1111
status_code: 301
1212

1313
- name: Test that nginx acts as proxy on https
1414
ansible.builtin.uri:
15-
url: https://127.0.0.1/
15+
url: https://{{ inventory_hostname }}/
1616
validate_certs: false
1717
follow_redirects: none
1818
status_code: 502
@@ -30,7 +30,7 @@
3030

3131
- name: Test extra configuration
3232
ansible.builtin.uri:
33-
url: https://127.0.0.1/test
33+
url: https://{{ inventory_hostname }}/test
3434
validate_certs: false
3535
follow_redirects: none
3636
status_code: 204

templates/nginx.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,7 @@ http {
153153
# Include additional custom configuration
154154
include /etc/nginx/conf.d/extra.conf;
155155
}
156+
157+
# Include dynamic virtual host configurations
158+
include /etc/nginx/sites-enabled/*;
156159
}

0 commit comments

Comments
 (0)