仅在单个端口 8080 上转发到本地主机(Windows)可能吗?

发布于 2024-07-09 19:07:38 字数 1477 浏览 13 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

秋风の叶未落 2024-07-16 19:07:38

Internet Junkbuster(代理服务器)可以使用其转发功能来执行此操作。

只需添加类似于 sforward.ini 的行

example.com:8080   localhost:80   .   .

,并取消注释 junkbstr.ini 中的 forwardfile 行即可。 现在将您的浏览器配置为使用在本地主机的端口 8000 上运行的代理服务器,然后就完成了。

我确信其他代理服务器也有类似的功能 - 我只是喜欢 Junkbuster,因为它是一个简单的独立可执行文件。

Internet Junkbuster (a proxy server) can do this using its forwarding functionality.

Just add a line like

example.com:8080   localhost:80   .   .

to sforward.ini, and uncomment the forwardfile line in junkbstr.ini. Now configure your browser to use a proxyserver running at port 8000 of localhost, and you're set.

I'm sure other proxy servers have a similar feature — I just like Junkbuster since it's a simple standalone executable.

人心善变 2024-07-16 19:07:38

您正在涉足域名服务 (DNS) 领域。 从技术上讲,通过高级 DNS 配置(可以包括重新映射端口),您的建议是可能的,并且可以在 Internet 上常规完成。 然而,您不太可能愿意在当地花费那么多的麻烦和费用。

另一方面,我怀疑您的真正问题可以更容易解决。 为什么您希望将“example.com”解析为您的本地 Web 服务器? 您已经可以将本地 Web 服务器引用为“localhost”、“127.0.0.1”,并通过其分配的计算机名称“workstation-x”。

我能想到并且我已经看到的想要引用与生产 Web 服务器具有相同主机名的本地 Web 服务器的唯一原因是由于将服务器主机名硬编码到应用程序 Web 中的链接中页。 如果是这种情况,答案很简单:不要! 您应该始终实现您的 Web 应用程序,以便它们引用与已部署服务器相关的所有内容(其他页面、CSS、JS、图像等)。 如果您跨多个服务器进行部署,则您的引用必须是基于可配置服务器主机名的绝对引用。 这很容易做到,没有理由不这样做。

如果情况并非如此,请解释您想要实现的目标以及促使您尝试的动机。

编辑:既然您已经证实了我的猜测,即问题是对网页中生产主机名的硬编码引用,那么让我简单地补充一下,我总是无一例外地发现解决真正的问题比解决实际问题更便宜积累解决方法(例如尝试重新映射端口)。 我从未遇到过持相反观点的作者。

修复页面应该比全局搜索和搜索稍微困难一些。 替换,尤其是使用像样的文本编辑器。 即使编写一个简单的脚本来更改源文件也会比尝试解决方法便宜得多且容易得多。

无论如何,祝您一切顺利,并让我们知道结果如何。

You are playing in the area of domain name services (DNS). Technically, with an advanced DNS configuration (which can include remapping ports), what you propose is possible and it is done routinely on the Internet. However, it is unlikely that you would want to go to that much trouble and expense locally.

On the other hand, I suspect that your real issue can be addressed more easily. Why would you want to have "example.com" resolve to your local web server? You can already reference your local web server as "localhost", as "127.0.0.1", and via its assigned machine name "workstation-x".

The only reason that I can think of, and that I have seen, for wanting to reference your local web server with the same host name as your production web server is due to hard-coding the server host name into your links within your application's web pages. If that is the case here, the answer is simple: don't! You should ALWAYS implement your web applications so that they reference everything (other pages, CSS, JS, images, etc.) relative to the deployed server. If you deploy across multiple servers, then your references must be absolute based on configurable server host names. This is easy to do, and there is no reason not to do it.

If this is not the case, then please explain what you are trying to achieve and what motivates you to try.

EDIT: Since you have confirmed my guess that the problem is hard-coded references to the production host name in the web pages, let me simply add that I have ALWAYS, WITHOUT EXCEPTION, found that it is cheaper to fix the real problem than to accumulate workarounds (such as your attempt to remap ports). I have never encountered an author who has argued the opposite.

Fixing the pages should be little harder than a global search & replace, especially with a decent text editor. Even writing a simple script to change the source files would be vastly cheaper and easier than your attempts at a workaround.

Regardless, best wishes to you, and let us know how it turned out.

南薇 2024-07-16 19:07:38

你能确认8080端口是否正在监听网络服务器吗? 使用命令“netstat -na”查看端口 8080 是否正在监听。

您是否在 apache 配置文件中添加了与默认 80 端口相同的 8080 端口?

一旦你在apache配置文件上添加端口8080以使其监听并仔细检查8080端口是否正在监听网络服务器,那么你将能够使用端口8080访问页面。就像http://mytestwebserver:8080/index.html 或类似的东西......

Can you confirm if 8080 port is listening on webserver? use the command "netstat -na" to see if the port 8080 is listening.

Did you add 8080 port on apache config file as the same as the default 80 port?

Once you add port 8080 on apache config file to make it listen and double check if 8080 port is listening on webserver, then you will be able to access the page using port 8080. like http://mytestwebserver:8080/index.html or something like this....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文