aboutsummaryrefslogtreecommitdiffhomepage
path: root/services/nuldoc/nginx.conf
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-11-02 20:04:43 +0900
committernsfisis <nsfisis@gmail.com>2025-11-02 20:04:43 +0900
commit3ee122e2eb6102b5fa100017c4a7ffead23bdc1d (patch)
tree4c8598861a1ec758e787ce123e4e8fbd72eb6a36 /services/nuldoc/nginx.conf
parente9c287f2a8dfc477f42efbae69a667b341f21982 (diff)
downloadnsfisis.dev-3ee122e2eb6102b5fa100017c4a7ffead23bdc1d.tar.gz
nsfisis.dev-3ee122e2eb6102b5fa100017c4a7ffead23bdc1d.tar.zst
nsfisis.dev-3ee122e2eb6102b5fa100017c4a7ffead23bdc1d.zip
feat(nuldoc): host each site in separate domains
Diffstat (limited to 'services/nuldoc/nginx.conf')
-rw-r--r--services/nuldoc/nginx.conf60
1 files changed, 58 insertions, 2 deletions
diff --git a/services/nuldoc/nginx.conf b/services/nuldoc/nginx.conf
index 311f600..a67b6ba 100644
--- a/services/nuldoc/nginx.conf
+++ b/services/nuldoc/nginx.conf
@@ -1,11 +1,47 @@
map $http_x_forwarded_host $docroot_path {
hostnames;
- default /public/_;
+ default /public/default;
about.* /public/about;
blog.* /public/blog;
slides.* /public/slides;
}
+map $http_x_forwarded_host $about_domain {
+ hostnames;
+ default about.nsfisis.dev;
+ *.localhost:8000 about.localhost:8000;
+}
+
+map $http_x_forwarded_host $blog_domain {
+ hostnames;
+ default blog.nsfisis.dev;
+ *.localhost:8000 blog.localhost:8000;
+}
+
+map $http_x_forwarded_host $slides_domain {
+ hostnames;
+ default slides.nsfisis.dev;
+ *.localhost:8000 slides.localhost:8000;
+}
+
+map $http_x_forwarded_host $is_about_domain {
+ hostnames;
+ default 0;
+ about.* 1;
+}
+
+map $http_x_forwarded_host $is_blog_domain {
+ hostnames;
+ default 0;
+ blog.* 1;
+}
+
+map $http_x_forwarded_host $is_slides_domain {
+ hostnames;
+ default 0;
+ slides.* 1;
+}
+
server {
listen 80 default;
listen [::]:80;
@@ -27,7 +63,16 @@ server {
error_page 404 /404.html;
# Redirect to canonical path.
- rewrite ^/posts/1/?$ /posts/ permanent;
+ rewrite ^/posts/1/?$ /posts/ permanent;
+ rewrite ^/slides/1/?$ /slides/ permanent;
+
+ # Redirect to posts/slides pages.
+ if ($is_blog_domain) {
+ rewrite ^/?$ /posts/ permanent;
+ }
+ if ($is_slides_domain) {
+ rewrite ^/?$ /slides/ permanent;
+ }
# Old URL patterns.
rewrite ^/posts/(my-first-post)/?$ /posts/2021-03-05/$1/ permanent;
@@ -46,4 +91,15 @@ server {
# Renamed posts.
rewrite ^/posts/2024-03-20/todos-in-my-life/?$ /posts/2024-03-20/my-bucket-list/ permanent;
+
+ # Redirect to new domains.
+ if ($is_about_domain = 0) {
+ rewrite ^/about/?$ http://$about_domain/ permanent;
+ }
+ if ($is_blog_domain = 0) {
+ rewrite ^/posts/(.*)/?$ http://$blog_domain/posts/$1/ permanent;
+ }
+ if ($is_slides_domain = 0) {
+ rewrite ^/slides/(.*)/?$ http://$slides_domain/slides/$1/ permanent;
+ }
}