| 
									
										
										
										
											2025-05-03 22:30:39 +01:00
										 |  |  | { config, ... }: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-18 18:28:17 +01:00
										 |  |  | let | 
					
						
							| 
									
										
										
										
											2025-05-03 22:30:39 +01:00
										 |  |  |   ports = config.homelab.ports; | 
					
						
							|  |  |  |   port = ports.nginx-website-sculpin; | 
					
						
							| 
									
										
										
										
											2025-04-18 18:28:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-03 22:57:57 +01:00
										 |  |  |   redirects = builtins.concatStringsSep "\n" ( | 
					
						
							|  |  |  |     map (r: "rewrite ^${r.from}/?$ ${r.to} redirect;") (import ./redirects.nix) | 
					
						
							| 
									
										
										
										
											2025-04-18 18:28:17 +01:00
										 |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-29 23:54:55 +01:00
										 |  |  |   tome = { | 
					
						
							|  |  |  |     root = "/var/www/vhosts/website-tome"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     paths = [ | 
					
						
							| 
									
										
										
										
											2025-05-11 15:03:00 +01:00
										 |  |  |       "archive" | 
					
						
							| 
									
										
										
										
											2025-07-02 07:54:35 +01:00
										 |  |  |       "automated-testing" | 
					
						
							| 
									
										
										
										
											2025-04-29 23:54:55 +01:00
										 |  |  |       "core" | 
					
						
							| 
									
										
										
										
											2025-05-11 15:03:00 +01:00
										 |  |  |       "daily/.+" | 
					
						
							| 
									
										
										
										
											2025-04-29 23:54:55 +01:00
										 |  |  |       "examples" | 
					
						
							| 
									
										
										
										
											2025-05-11 15:03:16 +01:00
										 |  |  |       "homelab" | 
					
						
							| 
									
										
										
										
											2025-05-26 00:54:42 +01:00
										 |  |  |       "podcast" | 
					
						
							| 
									
										
										
										
											2025-06-22 10:57:37 +01:00
										 |  |  |       "rss/bb.xml" | 
					
						
							| 
									
										
										
										
											2025-05-12 19:12:17 +01:00
										 |  |  |       "rss/daily.xml" | 
					
						
							| 
									
										
										
										
											2025-04-29 23:54:55 +01:00
										 |  |  |       "sites/default/files" | 
					
						
							| 
									
										
										
										
											2025-07-02 07:54:35 +01:00
										 |  |  |       "testing" | 
					
						
							| 
									
										
										
										
											2025-04-29 23:54:55 +01:00
										 |  |  |       "themes/custom/opdavies" | 
					
						
							|  |  |  |       "tome-test" | 
					
						
							|  |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-03 22:30:39 +01:00
										 |  |  |     port = ports.nginx-website-tome; | 
					
						
							| 
									
										
										
										
											2025-04-29 23:54:55 +01:00
										 |  |  |   }; | 
					
						
							| 
									
										
										
										
											2025-04-18 18:28:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   tomeLocations = builtins.listToAttrs ( | 
					
						
							|  |  |  |     map (path: { | 
					
						
							| 
									
										
										
										
											2025-07-23 22:31:59 +01:00
										 |  |  |       name = "~ ^/${path}"; | 
					
						
							| 
									
										
										
										
											2025-04-18 18:28:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       value = { | 
					
						
							| 
									
										
										
										
											2025-04-29 23:54:55 +01:00
										 |  |  |         root = tome.root; | 
					
						
							| 
									
										
										
										
											2025-04-18 18:28:17 +01:00
										 |  |  |         tryFiles = "$uri $uri.html $uri/index.html =404"; | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2025-04-29 23:54:55 +01:00
										 |  |  |     }) tome.paths | 
					
						
							| 
									
										
										
										
											2025-04-18 18:28:17 +01:00
										 |  |  |   ); | 
					
						
							|  |  |  | in | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   services = { | 
					
						
							|  |  |  |     nginx.virtualHosts = { | 
					
						
							|  |  |  |       "www.oliverdavies.uk" = { | 
					
						
							| 
									
										
										
										
											2025-04-21 12:58:45 +01:00
										 |  |  |         root = "/var/www/vhosts/website-sculpin"; | 
					
						
							| 
									
										
										
										
											2025-04-18 18:28:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         listen = [ | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             inherit port; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             addr = "localhost"; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         locations = tomeLocations // { | 
					
						
							|  |  |  |           "/".tryFiles = "$uri $uri.html $uri/index.html =404"; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         extraConfig = ''
 | 
					
						
							|  |  |  |           port_in_redirect off; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           # Remove trailing slashes. | 
					
						
							|  |  |  |           rewrite ^/(.*)/$ /$1 permanent; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           error_page 404 /404; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           rewrite ^/talks/archive/?$ /talks permanent; | 
					
						
							|  |  |  |           rewrite ^/talks/(.*)$ /presentations/$1 permanent; | 
					
						
							|  |  |  |           rewrite ^/talks/?$ /presentations permanent; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-03 22:57:57 +01:00
										 |  |  |           ${redirects} | 
					
						
							| 
									
										
										
										
											2025-04-18 18:28:17 +01:00
										 |  |  |         '';
 | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-29 15:00:05 +01:00
										 |  |  |       "oliverdavies.uk" = { | 
					
						
							|  |  |  |         forceSSL = true; | 
					
						
							|  |  |  |         globalRedirect = "www.oliverdavies.uk"; | 
					
						
							|  |  |  |         useACMEHost = "oliverdavies.uk"; | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2025-04-29 23:54:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       "tome.oliverdavies.uk" = { | 
					
						
							|  |  |  |         listen = [ | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             addr = "localhost"; | 
					
						
							|  |  |  |             port = tome.port; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         locations."/".tryFiles = "$uri $uri.html $uri/index.html =404"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         root = tome.root; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         extraConfig = ''
 | 
					
						
							|  |  |  |           add_header X-Robots-Tag "noindex, nofollow"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           port_in_redirect off; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           # Remove trailing slashes. | 
					
						
							|  |  |  |           rewrite ^/(.*)/$ /$1 permanent; | 
					
						
							|  |  |  |         '';
 | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2025-04-18 18:28:17 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     cloudflared.tunnels."e1514105-327f-4984-974e-e2fbaca76466" = { | 
					
						
							|  |  |  |       ingress = { | 
					
						
							|  |  |  |         "oliverdavies.uk" = "http://localhost:${toString port}"; | 
					
						
							| 
									
										
										
										
											2025-04-29 23:54:55 +01:00
										 |  |  |         "tome.oliverdavies.uk" = "http://localhost:${toString tome.port}"; | 
					
						
							| 
									
										
										
										
											2025-04-18 18:28:17 +01:00
										 |  |  |         "www.oliverdavies.uk" = "http://localhost:${toString port}"; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | } |