aboutsummaryrefslogtreecommitdiffstats
path: root/templates/ingress
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-10-06 13:18:33 +0300
committerJan Tuomi <jan@jantuomi.fi>2025-10-06 13:18:33 +0300
commit29eb2e6cc469d9534c2586e98b782f1879bd8c76 (patch)
treeef2d0bd53087b04bc395dd96d7f6da9bfe69b470 /templates/ingress
parent0bf8f1d7f9e477b2de52ab1e7aea000eff8666fe (diff)
Refactor, add certbot to cron
Diffstat (limited to 'templates/ingress')
-rw-r--r--templates/ingress/etc_crontab.j210
-rw-r--r--templates/ingress/usr_local_etc_nginx_nginx.conf.j277
2 files changed, 87 insertions, 0 deletions
diff --git a/templates/ingress/etc_crontab.j2 b/templates/ingress/etc_crontab.j2
new file mode 100644
index 0000000..7308565
--- /dev/null
+++ b/templates/ingress/etc_crontab.j2
@@ -0,0 +1,10 @@
+# /etc/crontab - root's crontab for FreeBSD
+#
+#
+SHELL=/bin/sh
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
+#
+#minute hour mday month wday who command
+
+# Update LetsEncrypt certificates every day at 2:00 AM
+0 2 * * * root certbot certonly --nginx -n -m jan@jantuomi.fi --agree-tos -d {{ items }}
diff --git a/templates/ingress/usr_local_etc_nginx_nginx.conf.j2 b/templates/ingress/usr_local_etc_nginx_nginx.conf.j2
new file mode 100644
index 0000000..cee7878
--- /dev/null
+++ b/templates/ingress/usr_local_etc_nginx_nginx.conf.j2
@@ -0,0 +1,77 @@
+worker_processes auto;
+
+events {
+ worker_connections 1024;
+}
+
+http {
+ include mime.types;
+ default_type application/octet-stream;
+
+ sendfile on;
+ keepalive_timeout 65;
+
+ server {
+ listen 80 default_server;
+ server_name _;
+
+ location / {
+ return 404;
+ }
+ }
+
+ {% for site in static_sites -%}
+ {% if site.tls -%}
+ server {
+ server_name {{ site.host }};
+ root /usr/local/www/{{ site.site }};
+
+ listen 443 ssl;
+ listen [::]:443 ssl;
+ http2 on;
+
+ index index.html;
+
+ location / {
+ try_files $uri $uri.html $uri/ =404;
+ }
+
+ # See https://ssl-config.mozilla.org/#server=nginx&version=1.28.0&config=intermediate&openssl=3.4.0&guideline=5.7
+ add_header Strict-Transport-Security "max-age=63072000" always;
+
+ access_log /var/log/nginx/{{ site.site }}/access.log;
+ error_log /var/log/nginx/{{ site.site }}/error.log;
+
+ ssl_certificate /usr/local/etc/letsencrypt/live/{{ site.host }}/fullchain.pem;
+ ssl_certificate_key /usr/local/etc/letsencrypt/live/{{ site.host }}/privkey.pem;
+ include /usr/local/etc/letsencrypt/options-ssl-nginx.conf;
+ ssl_dhparam /usr/local/etc/letsencrypt/ssl-dhparams.pem;
+ }
+ {% endif -%}
+
+ server {
+ listen 80;
+ server_name {{ site.host }};
+
+ return 301 https://$host$request_uri;
+
+ access_log /var/log/nginx/{{ site.site }}/access.log;
+ error_log /var/log/nginx/{{ site.site }}/error.log;
+ }
+
+ {% endfor -%}
+ {% for jail in jails -%}
+ server {
+ listen 80;
+ server_name {{ jail.name }}.jan.systems {{ jail.name }}.local.jan.systems;
+
+ location / {
+ proxy_pass http://192.168.2.{{ jail.num }};
+ 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;
+ }
+ }
+ {% endfor %}
+}