仅在单个端口8080上转发到本地主机(Windows)可能吗? [英] Forwarding only on a single port 8080 to localhost (windows) possible?

查看:135
本文介绍了仅在单个端口8080上转发到本地主机(Windows)可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何在Windows上使用xampp设置本地Web服务器...我在主机文件(c:\ windows \ system32 \ drivers \ etc \ hosts)上输入别名和目标,然后在我的apache vhosts配置文件.这样,假设我的Web服务器正在侦听端口80,例如,我可以将example.com映射到我的本地Web服务器.

I know how to set up a local webserver using xampp on windows... I enter my alias and target on the hosts file (c:\windows\system32\drivers\etc\hosts) and then add a respective entry on my apache vhosts config file. This way, assuming that my webserver is listening to port 80, I can for example map example.com to my local webserver.

我一直在我的hosts文件中输入整个域名(例如example.com),并且对该名称的任何请求都将定向到localhost.

I've always entered the whole domain name (that is e.g. example.com) in my hosts file and any requests on that name would be directed to localhost.

现在,我在想是否有办法仅在特定端口上转发example.com (例如,仅example.com:8080)到本地网络服务器,而将example.com(保留在单独使用默认端口80),这样它仍然可以访问我的实时制作网站.

Now I was wondering if there's a way to only forward example.com on a certain port (for example only example.com:8080) to the local webserver, and leave example.com (on the default port 80) alone, so that it would still go to my live production website.

据我了解,仅使用主机文件可能无法实现(我尝试将端口8080添加到我的域名中-似乎没有用;-))...

As far as I understand this might not be possible using only the hosts file (I tried adding the port :8080 to my domain names - didn't seem work ;-) )...

我对这个主题真的不太了解,因此欢迎任何想法,见解,链接,阅读材料,工具.

I really don't know much on this topic so any ideas, insights, links, reading material, tools are welcome.

Arnout的答复回答了我上面已经问过的问题,但不能解决我的实际问题.将example.com:8080重新路由到localhost:80确实可行,如果我访问example.com,它将加载本地版本的首页,但是该页面上的所有链接当然都不知道端口号,因此指向生产版本...解决我的问题的实际方法似乎是咬进酸的苹果,并按照Rob的建议 fix (并遵循Rob的建议)并删除所有硬编码的url,以便它可以在任何域上使用. ..

Arnout's reply answers the question I've asked above but doesn't solve my actual problem. Rerouting example.com:8080 to localhost:80 does work and if I access example.com it loads up the frontpage of my local version, but all links on that page of course don't know about the port number and therefore point to the production version... The actual solution to my problem seems to be to bite into the sour apple and fix my application (following Rob's suggestion) and remove all hardcoded urls, so that it works on any domain...

推荐答案

Internet Junkbuster(代理服务器)可以使用其转发功能.

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

只需添加一行

example.com:8080   localhost:80   .   .

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

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.

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

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

这篇关于仅在单个端口8080上转发到本地主机(Windows)可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆