diff --git a/infra/inventory.ini b/infra/inventory.ini index 21e666d..483ec0f 100644 --- a/infra/inventory.ini +++ b/infra/inventory.ini @@ -1,5 +1,5 @@ [staging] -staging.earthmanrpg.me ansible_user=discoman ansible_ssh_private_key_file=~/.ssh/id_ed25519_wsl_python-tdd +staging.earthmanrpg.me ansible_user=discoman ansible_ssh_private_key_file=~/.ssh/id_ed25519_wsl_python-tdd letsencrypt_domain=staging.earthmanrpg.me [production] www.earthmanrpg.me ansible_user=discoman ansible_ssh_private_key_file=~/.ssh/id_ed25519_wsl_python-tdd diff --git a/infra/nginx.conf.j2 b/infra/nginx.conf.j2 index 937380e..57f7c97 100644 --- a/infra/nginx.conf.j2 +++ b/infra/nginx.conf.j2 @@ -1,6 +1,15 @@ server { listen 80; server_name {{ django_allowed_host | replace(',', ' ')}}; + return 301 https://$host$request_uri; +} + +server { + listen 443 ssl; + server_name {{ django_allowed_host | replace(',', ' ') }}; + + ssl_certificate /etc/letsencrypt/live/{{ letsencrypt_domain }}/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/{{ letsencrypt_domain }}/privkey.pem; location /static/ { alias /var/www/gamearray/static/; @@ -11,6 +20,6 @@ server { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Proto https; } } \ No newline at end of file