我试图用一个子站点redirect的非标准端口上的Minecraft服务器设置我的服务器,当我的浏览器导航到其正确的端口,或者如果通过网页浏览器导航将显示一个网页。 即:
**Minecraft** minecraft.example.com:25565 -> example.com:25465 **Web Browser** minecraft.example.com:80 -> Displays HTML Page
我试图通过在Apache中使用以下VirtualHosts来做到这一点:
Listen 25565 <VirtualHost *:80> ServerAdmin [email protected] ServerName minecraft.example.com DocumentRoot /var/www/example.com/minecraft <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/example.com/minecraft/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost> <VirtualHost *:25565> ServerAdmin [email protected] ServerName minecraft.example.com ProxyPass / http://localhost:25465 retry=1 acquire=3000 timeout=6$ ProxyPassReverse / http://localhost:25465 </VirtualHost>
浏览到minecraft.example.com时运行此configuration我可以在/var/www/example.com/minecraft/文件夹中看到这些文件,但是如果我在“我的世界”中尝试连接,则会收到一个exception,并在浏览器我得到一个包含以下信息的页面:
minecraft.example.com:25565 -> Proxy Error The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /. Reason: Error reading from remote server
任何人都可以分享一些我可能做错的见解,以及解决这个问题最好的解决办法是什么?
我的世界服务器协议不是HTTP,所以你不能代理这样的请求。
假设你在Linux上,使用iptables转发TCP端口。 您仍然可以在同一个IP上的端口80上运行Apache,但是在您的configuration中删除了Listen指令和相应的vhost。
IPTables规则应该是这样的:
iptables -t nat -A PREROUTING -p tcp -d –dport 25565 -j DNAT – 到127.0.0.1:25465
当然,记得实际上允许在INPUT / OUTPUT链中input一个条目。
iptables -t nat -A PREROUTING -p tcp -d 12.13.14.15 --dport 25565 -j DNAT --to 127.0.0.1:25465
其中12.13.14.15是minecraft.example.com的IP地址。
注意,您不能使用虚拟主机。 如果你想在同一个公共IP上托pipeserver1.example.com和minecraft.example.com,都要做这种端口级别的redirect…抱歉,不会发生。 这个东西发生在 HTTP层之前 ,所以虚拟主机与它无关。 🙂