list Local Access URLs for this server

This commit is contained in:
ljm42
2022-07-01 15:11:58 -07:00
parent f5d61743d3
commit f6f1afeef1
2 changed files with 65 additions and 0 deletions

View File

@@ -1153,6 +1153,13 @@ Select **Strict** to enable *exclusive* use of an Unraid.net SSL
certificate for https access (see **Provision** below). Note that a DNS
server must be reachable.
**Redirects:** When accessing `http://<server-ip-address>` or `http://<server-name>.<localTLD>`, the
behavior will change depending on the value of the Use SSL/TLS setting:
* If Use SSL/TLS is set to **Strict**, you will be redirected to `https://<lan-ip>.<hash>.myunraid.net`
* If Use SSL/TLS is set to **Yes**, you will be redirected to `https://<server-ip-address> or https://<server-name>.<localTLD>`
* If Use SSL/TLS is set to **No**, then the http url will load directly.
Important: **Strict** may not be selectable if your router or upstream DNS server has
[DNS rebinding protection](https://en.wikipedia.org/wiki/DNS_rebinding) enabled. DNS rebinding
protection prevents DNS from resolving a private IP network range. DNS rebinding protection is meant as
@@ -1200,6 +1207,11 @@ Enter the HTTPS port, default port is 443.
Enter your local Top Level Domain. May be blank.
:end
:mgmt_local_access_urls_help:
The Local Access URLs shown above are based on your current settings.
To adjust URLs or redirects, see the help text for "Use SSL/TLS".
:end
:mgmt_certificate_expiration_help:
**Provision** may be used to install a *free* Unraid.net SSL Certificate from
[Let's Encrypt](https://letsencrypt.org/).

View File

@@ -108,6 +108,41 @@ if ($cert2Present) {
}
}
$nginx = parse_ini_file('/var/local/emhttp/nginx.ini');
$http_port = $var['PORT'] != 80 ? ":{$var['PORT']}" : '';
$https_port = $var['PORTSSL'] != 443 ? ":{$var['PORTSSL']}" : '';
$http_ip_url = "http://{$nginx['NGINX_LANIP']}{$http_port}/";
$http_url = "http://{$nginx['NGINX_LANMDNS']}{$http_port}/";
$https_ip_url = "https://{$nginx['NGINX_LANIP']}{$https_port}/";
$https_url = "https://{$nginx['NGINX_LANMDNS']}{$https_port}/";
$https_2_url = "https://{$nginx['NGINX_LANFQDN']}{$https_port}/";
$urls = array();
// push an array of three values into the $urls array:
// 0 - the url
// 1 - the url it redirects to, or null
// 2 - the certificate file used, or null
switch($var['USE_SSL']) {
case 'no':
$urls[] = [$http_ip_url, null, null];
$urls[] = [$http_url, null, null];
if ($nginx['NGINX_LANFQDN']) $urls[] = [$https_2_url, null, "certificate_bundle.pem"];
break;
case 'yes':
$urls[] = [$http_ip_url, $https_ip_url, null];
$urls[] = [$https_ip_url, null, "{$var['NAME']}_unraid_bundle.pem"];
$urls[] = [$http_url, $https_url, null];
$urls[] = [$https_url, null, "{$var['NAME']}_unraid_bundle.pem"];
if ($nginx['NGINX_LANFQDN']) $urls[] = [$https_2_url, null, "certificate_bundle.pem"];
break;
case 'auto': // aka strict
$urls[] = [$http_ip_url, $https_2_url, null];
$urls[] = [$http_url, $https_2_url, null];
$urls[] = [$https_2_url, null, "certificate_bundle.pem"];
break;
}
$cert_time_format = $display['date'].($display['date']!='%c' ? ', '.str_replace(['%M','%R'],['%M:%S','%R:%S'],$display['time']):'');
$provisionlabel = $isLEcert ? _('Renew') : _('Provision');
$disabled_provision = $keyfile===false || ($isLEcert && $retval_expired===0) ? 'disabled' : '';
@@ -301,6 +336,24 @@ _(Local TLD)_:
</form>
<div style="height:24px"></div>
<form markdown="1">
<?
echo "<dl><dt>"._("Local Access URLs").":</dt>\n";
echo "<dd><br><ul>\n";
foreach($urls as $url) {
if ($url[1]) $msg = " ("._("redirects to")." <a href='{$url[1]}'>{$url[1]}</a>)";
if ($url[2]) $msg = " ("._("uses certificate")." {$url[2]} )";
echo "<li><a href='{$url[0]}'>{$url[0]}</a>{$msg}</li>\n";
}
echo "</ul></dd></dl>\n";
?>
:mgmt_local_access_urls_help:
</form>
<div style="height:24px"></div>
<form markdown="1">
<?if ($cert1Present):?>