From 943ca92c3220ddde6229ab45113c1e3a348c06b9 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Sat, 14 Jun 2025 13:49:28 -0700 Subject: [PATCH] Serve webdevcat.me and subdomains with https --- conf/nginx.conf | 33 ++++++++++++++++++----- spec/nginx_spec.moon | 64 ++++++++++++++++++++++---------------------- 2 files changed, 59 insertions(+), 38 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index cb7e34c..69329bb 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -79,33 +79,54 @@ http { } server { - # listen 443 ssl; + listen 443 ssl; server_name webdevcat.me; include mime.types; charset utf-8; default_type text/html; + ssl_certificate /var/www/certs/webdevcat.me/fullchain.pem; + ssl_certificate_key /var/www/certs/webdevcat.me/privkey.pem; + location / { - return 301 http://miti.sh$request_uri; + return 301 https://miti.sh$request_uri; } location ~ ^/git/?(.*)$ { - return 301 http://git.miti.sh/ccm/$1; + return 301 https://git.miti.sh/ccm/$1; } location ~ ^/apps/(.*)$ { - return 301 http://apps.miti.sh/$1; + return 301 https://apps.miti.sh/$1; } } server { + listen 443 ssl; server_name git.webdevcat.me; - return 301 http://git.miti.sh$request_uri; + + ssl_certificate /var/www/certs/webdevcat.me/fullchain.pem; + ssl_certificate_key /var/www/certs/webdevcat.me/privkey.pem; + + location ^~ /.well-known/acme-challenge { + alias /var/www/dehydrated; + } + + return 301 https://git.miti.sh$request_uri; } server { + listen 443 ssl; server_name apps.webdevcat.me; - return 301 http://apps.miti.sh$request_uri; + + ssl_certificate /var/www/certs/webdevcat.me/fullchain.pem; + ssl_certificate_key /var/www/certs/webdevcat.me/privkey.pem; + + location ^~ /.well-known/acme-challenge { + alias /var/www/dehydrated; + } + + return 301 https://apps.miti.sh$request_uri; } } diff --git a/spec/nginx_spec.moon b/spec/nginx_spec.moon index c0c481c..dfd8403 100644 --- a/spec/nginx_spec.moon +++ b/spec/nginx_spec.moon @@ -18,61 +18,61 @@ describe "http://miti.sh", -> assert.same request\statusMessage!, "Moved Permanently" assert.same request\header!.Location, "https://miti.sh/" -describe "http://webdevcat.me", -> - it "permanently redirects to http://miti.sh", -> - request = req "http://webdevcat.me" +describe "https://webdevcat.me", -> + it "permanently redirects to https://miti.sh", -> + request = req "https://webdevcat.me" assert.same request\statusCode!, 301 assert.same request\statusMessage!, "Moved Permanently" - assert.same request\header!.Location, "http://miti.sh/" + assert.same request\header!.Location, "https://miti.sh/" -describe "http://webdevcat.me/git", -> - it "permanently redirects to http://git.miti.sh/ccm/", -> - request = req "http://webdevcat.me/git" +describe "https://webdevcat.me/git", -> + it "permanently redirects to https://git.miti.sh/ccm/", -> + request = req "https://webdevcat.me/git" assert.same request\statusCode!, 301 assert.same request\statusMessage!, "Moved Permanently" - assert.same request\header!.Location, "http://git.miti.sh/ccm/" + assert.same request\header!.Location, "https://git.miti.sh/ccm/" -describe "http://webdevcat.me/git/", -> - it "permanently redirects to http://git.miti.sh", -> - request = req "http://webdevcat.me/git" +describe "https://webdevcat.me/git/", -> + it "permanently redirects to https://git.miti.sh", -> + request = req "https://webdevcat.me/git" assert.same request\statusCode!, 301 assert.same request\statusMessage!, "Moved Permanently" - assert.same request\header!.Location, "http://git.miti.sh/ccm/" + assert.same request\header!.Location, "https://git.miti.sh/ccm/" -describe "http://webdevcat.me/git/pandoc", -> - it "permanently redirects to http://git.miti.sh/ccm/pandoc", -> - request = req "http://webdevcat.me/git/pandoc" +describe "https://webdevcat.me/git/pandoc", -> + it "permanently redirects to https://git.miti.sh/ccm/pandoc", -> + request = req "https://webdevcat.me/git/pandoc" assert.same request\statusCode!, 301 assert.same request\statusMessage!, "Moved Permanently" - assert.same request\header!.Location, "http://git.miti.sh/ccm/pandoc" + assert.same request\header!.Location, "https://git.miti.sh/ccm/pandoc" -describe "http://git.webdevcat.me", -> - it "permanently redirects to http://git.miti.sh/", -> - request = req "http://git.webdevcat.me" +describe "https://git.webdevcat.me", -> + it "permanently redirects to https://git.miti.sh/", -> + request = req "https://git.webdevcat.me" assert.same request\statusCode!, 301 assert.same request\statusMessage!, "Moved Permanently" - assert.same request\header!.Location, "http://git.miti.sh/" + assert.same request\header!.Location, "https://git.miti.sh/" -describe "http://webdevcat.me/apps/btroops", -> - it "permanently redirects to http://apps.miti.sh/btroops", -> - request = req "http://webdevcat.me/apps/btroops" +describe "https://webdevcat.me/apps/btroops", -> + it "permanently redirects to https://apps.miti.sh/btroops", -> + request = req "https://webdevcat.me/apps/btroops" assert.same request\statusCode!, 301 assert.same request\statusMessage!, "Moved Permanently" - assert.same request\header!.Location, "http://apps.miti.sh/btroops" + assert.same request\header!.Location, "https://apps.miti.sh/btroops" -describe "http://apps.webdevcat.me", -> - it "permanently redirects to http://apps.miti.sh/", -> - request = req "http://apps.webdevcat.me" +describe "https://apps.webdevcat.me", -> + it "permanently redirects to https://apps.miti.sh/", -> + request = req "https://apps.webdevcat.me" assert.same request\statusCode!, 301 assert.same request\statusMessage!, "Moved Permanently" - assert.same request\header!.Location, "http://apps.miti.sh/" + assert.same request\header!.Location, "https://apps.miti.sh/" -describe "http://apps.webdevcat.me/btroops", -> - it "permanently redirects to http://apps.miti.sh/btroops", -> - request = req "http://apps.webdevcat.me/btroops" +describe "https://apps.webdevcat.me/btroops", -> + it "permanently redirects to https://apps.miti.sh/btroops", -> + request = req "https://apps.webdevcat.me/btroops" assert.same request\statusCode!, 301 assert.same request\statusMessage!, "Moved Permanently" - assert.same request\header!.Location, "http://apps.miti.sh/btroops" + assert.same request\header!.Location, "https://apps.miti.sh/btroops" describe "https://miti.sh", -> it "sends /index.html", ->