我正在尝试创建自己的动态 DNS 服务器。我想在家远程访问我自己的云和运行在我的树莓派上的 apache 网络服务器。我的 ipv4 不是公开的,但我有 ipv6 设置并且可以公开访问。
我有一个基于云的主机 (rpi.myownddns.abc) - 运行 apache - 我计划从中运行我的动态 DNS 服务。直到现在我:
在 rpi.myownddns.abc 上创建了一个 myip.php 页面,它将我当前的 ipv6 地址存储在 webhost 上的文本文件 (currentIP.text) 中(我的 rpi 有一个 bash 脚本(ddns 更新客户端),它使用我的 eth0 联系 myip.php ipv6 地址每小时)。
在 rpi.myownddns.abc 上创建了一个 index.php 页面,它将我重定向到最新更新的 ipv6 地址。
index.php
<?php
$myFile = "currentIP.txt";
$fh = fopen($myFile, 'r');
$theIP = fread($fh, filesize($myFile));
fclose($fh);
//echo $theIP;
header('Location: https://['.$theIP.']');
?>
每当我访问 rpi.myownddns.abc 时,我都会按预期重定向到我的家庭服务器 ipv6。但是 URL 看起来像 https://[20a2:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]/。
例如,我希望我的 url 显示为 rpi.myownddns.abc/owncloud,类似于您从 ddns 提供商(ex noip)获得的内容。我如何实现这一目标?
我尝试使用 apache mod_rewrite,但只能实现与 php 相同的重定向。我检查了 mod_alias,但这似乎需要一个域名,而不是一个 IP 地址。
任何帮助或指针表示赞赏。谢谢。