Преглед на файлове

feat: essential configuration options for deployers

This commit makes everything a ton easier for deployers, adding
configuration options to allow nip.io domains or all origins to access
Puter for ideal LAN or VPN configurations.
KernelDeimos преди 3 месеца
родител
ревизия
3666b9f3a2
променени са 2 файла, в които са добавени 23 реда и са изтрити 1 реда
  1. 13 0
      doc/self-hosters/domains.md
  2. 10 1
      src/backend/src/modules/web/WebServerService.js

+ 13 - 0
doc/self-hosters/domains.md

@@ -6,6 +6,19 @@
 
 Ensure the hosting device has a static IP address to prevent potential connectivity issues due to IP changes. This setup will enable seamless access to Puter and its services across your local network.
 
+### Using `nip.io`
+
+We recommend this configuration for LAN setups. All you need to do is set the following
+at root level in your configuration file:
+
+```json
+  "allow_nipio_domains": true
+```
+
+Puter requires multiple origins to work correctly. `nip.io` is a wildcard DNS for IP addresses,
+so Puter can still have multiple subdomains and you don't need to configure your own DNS or
+hosts file.
+
 ### Using Hosts Files
 
 The hosts file is a straightforward way to map domain names to IP addresses on individual devices. It's simple to set up but requires manual changes on each device that needs access to the domains.

+ 10 - 1
src/backend/src/modules/web/WebServerService.js

@@ -449,13 +449,22 @@ class WebServerService extends BaseService {
                 'at.' + config.static_hosting_domain.toLowerCase(),
             ];
 
+            if ( config.allow_nipio_domains ) {
+                allowedDomains.push('nip.io');
+            }
+
             // Retrieve the Host header and ensure it's in a valid format
             const hostHeader = req.headers.host;
 
-            if (!hostHeader) {
+            if ( ! config.allow_no_host_header && ! hostHeader ) {
                 return res.status(400).send('Missing Host header.');
             }
 
+            if ( config.allow_all_host_values ) {
+                next();
+                return;
+            }
+
             // Parse the Host header to isolate the hostname (strip out port if present)
             const hostName = hostHeader.split(':')[0].trim().toLowerCase();