From: Jakub Czajka Date: Sat, 11 May 2024 22:55:44 +0000 (+0200) Subject: Put home page's content in a separate file and serve it through SSI. X-Git-Url: https://git.ekhem.eu.org/?a=commitdiff_plain;h=916d6bec122adb38e58a07c572d77663ccb5614e;p=website.git Put home page's content in a separate file and serve it through SSI. --- diff --git a/home.html b/home.html new file mode 100644 index 0000000..c23a9c0 --- /dev/null +++ b/home.html @@ -0,0 +1,42 @@ + + + +

Jakub Czajka's website 💪😎

+

About

+
+ +

Contact

+
+ +

Links

+
+ +

Articles

+
+ +
diff --git a/index.html b/index.html index 97e6320..d5264d0 100644 --- a/index.html +++ b/index.html @@ -23,19 +23,6 @@ border-style: double; padding: 5px; } - h3 { - margin-bottom: 0px; - } - p { - margin: auto 10px; - } - ul { - list-style-type: none; - padding-left: 15px; - } - li img { - height: 1em; - } .bottom-container { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; @@ -53,43 +40,7 @@
- -

Jakub Czajka's website 💪😎

-

About

-
- -

Contact

-
- -

Links

-
- -

Articles

-
- -

There's nothing here 🤔

-
+

Modified: 

diff --git a/website.conf b/website.conf index 5f471fa..26c16e9 100644 --- a/website.conf +++ b/website.conf @@ -44,8 +44,43 @@ server { add_header Content-Disposition 'inline'; } + # Dynamic SSI from + # https://www.nginx.com/resources/wiki/start/topics/examples/dynamic_ssi. + # + # If user requests /page.html, nginx should first serve /index.html which + # then requests /page.html. + # + # Simply rewriting /page.html to /index.html causes an infinite loop because + # /index.html requests /page.html. + # + # Instead, if user requests /index.html with /page.html, they should instead + # hit /page. + # 1. User requests /page. + # 2. Nginx serves /index.html. + # 3. /index.html requests /page.html. + # 4. /page.html serves page.html. location / { - index index.html; + ssi on; + + set ${dollar}content ${dollar}request_uri; + if (${dollar}request_uri = "/") { + set ${dollar}content "/home"; + } + if (!-f ${dollar}request_filename) { + rewrite ^ /index.html last; + } + if (!-f ${dollar}document_root${dollar}content.html) { + return 404; + } + } + + # /index.html is an edge case. + location = /index { + return 301 /; + } + + # Images should be served as-is. + location /media { } }