Skip to content

Commit bd09ecd

Browse files
evilhamstermanalessfg
authored andcommitted
Add support for enabling an http to https redirects (#82)
* Add support for enabling an http to https redirects * Remove extra curly brace * Update default.conf.j2 Remove another extra curly brace * Add redirect variable to defaults and readme
1 parent fe3caad commit bd09ecd

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ nginx_http_template:
328328
port: 8081
329329
server_name: localhost
330330
error_page: /usr/share/nginx/html
331+
redirect: false
331332
autoindex: false
332333
ssl:
333334
cert: ssl/default.crt

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ nginx_http_template:
161161
port: 8081
162162
server_name: localhost
163163
error_page: /usr/share/nginx/html
164+
redirect: false
164165
autoindex: false
165166
ssl:
166167
cert: ssl/default.crt

templates/http/default.conf.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ server {
2828
{% if item.value.autoindex is defined and item.value.autoindex %}
2929
autoindex on;
3030
{% endif %}
31+
{% if item.value.redirect is defined and item.value.redirect %}
32+
return 301 https://{{ item.value.server_name }}$request_uri;
33+
{% endif%}
3134
{% if item.value.load_balancer is defined %}
3235
{% for location in item.value.load_balancer.locations %}
3336
location {{ item.value.load_balancer.locations[location].location }} {

0 commit comments

Comments
 (0)