Apache 正在侦听不同的端口,但如何获取它以便不必输入端口号?

发布于 2024-07-11 20:16:31 字数 512 浏览 10 评论 0原文

我在本地主机上并行运行 IIS 和 Apache HTTP Server,而 Apache 正在侦听不同的端口(端口 81)。 IIS 正在监听端口 80。但是,如果我输入该端口号,我只能访问 Apache 的虚拟域。 例如:

http://virtual.myvirtualdomain.com:81 http://virtual.myvirtualdomain2.com:81

我怎样才能让Apache自动知道它是端口 81,并且不强制我输入端口号?

编辑:

答案似乎是我需要将 IIS 重定向到 Apache。 任何人都可以澄清如何使用 IIS 5.1 完成此操作吗?

I am running IIS and Apache HTTP Server side-by-side on my localhost machine, and Apache is listening on a different port (port 81). IIS is listening to port 80. However, I can only get to my virtual domains for Apache if I type in that port number. So for instance:

http://virtual.myvirtualdomain.com:81
http://virtual.myvirtualdomain2.com:81

How can I make it so Apache automatically knows it is port 81, and does not force me to type in the port number?

EDIT:

The answer appears to be that I need to redirect IIS to Apache. Can anyone provide clarification on how that is done with IIS 5.1?

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

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

发布评论

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

评论(8

别再吹冷风 2024-07-18 20:16:31

这不是告诉 Apache 的问题,而是浏览器知道要连接到什么的问题。 您要么必须将 IIS 重定向到 Apache,要么放弃。

It's not a matter of telling Apache, it's a matter of the browser knowing what to connect to. You're either going to have to have IIS redirect to Apache, or give up.

夏末的微笑 2024-07-18 20:16:31

您必须输入端口号,以便您的客户端知道连接到哪里。 这与服务器无关。

在 Unix 系统上,您可以修改 /etc/services 以将 81 列为 http 端口。 但这会有效地禁用对位于端口 80 上的所有网站的访问。

或者,您可以将端口 80 上的 IIS 配置为本地代理 apache 上网站的请求。 然后所有客户端都会向 IIS 请求一个页面,该页面将建立到端口 81 的本地连接。

You have to type in the port number so your client knows where to connect to. This has nothing to do with the server.

On Unix systems you might be able to modify your /etc/services to list 81 as port for http. But that would effectively disable access to all websites that are located on port 80.

Alternatively you can configure your IIS on port 80 to locally proxy requests for the sites which are on apache. Then all clients would ask the IIS for a page, which would make a local connection to port 81.

水晶透心 2024-07-18 20:16:31

我做了一些更多的研究,结果发现您无法将 IIS 5.1 重定向到 Apache,因为这需要多个网站(设置为重定向到端口 81 上的 Apache 上的虚拟主机)。 这是因为 Windows XP Pro 上的 IIS 5.1 无法处理多个网站(在没有脚本黑客的情况下同时运行)。 那好吧。

I did some more research and it turns out that you can't redirect IIS 5.1 to Apache because that would require multiple Web sites (setup as redirects to the virtual hosts on Apache on port 81). This is because IIS 5.1 on Windows XP Pro can't do multiple Web sites (running at the same time without the scripting hack). Oh well.

软糯酥胸 2024-07-18 20:16:31

你换一下怎么样? 让 Apache 在端口 80 上监听,让 IIS 在端口 81 上监听您需要的任何内容并让 Apache 重定向? Apache 不应该像 IIS 5.1 那样被限制为每台机器只有一个网站。

How about you swap it? Make Apache listen on port 80, IIS on port 81 for whatever you need and have Apache redirect? Apache shouldn't be restricted to the same one-website per machine that IIS 5.1 is.

带刺的爱情 2024-07-18 20:16:31

你不能。 81 告诉您的浏览器到哪里寻找 Apache。

You can't. The 81 is telling your browser where to look for Apache.

满意归宿 2024-07-18 20:16:31

你不能。

指定端口是网络客户端的工作,在您指定该端口之前,它甚至不会到达 Apache。

您可以做的是让 IIS 也侦听相同的 HTTP/1.1 虚拟主机,然后安排它发出 302 Moved 重定向,将您的浏览器发送到正确的端口号。

或者,在您的计算机上运行第二个 IP 地址,并将 IIS 绑定到原始 IP 地址,将 Apache 绑定到第二个 IP 地址。 这样您就根本不需要使用不同的端口。

You can't.

It's the job of your web client to specify the port, and until you do specify that port it won't even reach Apache.

What you could potentially do is have IIS also listen for the same HTTP/1.1 virtual hosts, and then arrange for it to issue a 302 Moved redirect to send your browser to the right port number.

Alternatively, run a second IP address on your machine, and bind IIS to the original IP address and Apache to the second. That way you don't need to use different ports at all.

莫言歌 2024-07-18 20:16:31

没有办法完全按照你的要求去做。 唯一的方法是配置 IIS(对于 IIS 所服务的虚拟域),使其在端口 81 上转发到 Apache。通过此配置,客户端不会意识到他们的请求正在通过 IIS 传递到阿帕奇。 效率稍低,但可以解决您的需求。

There is no way to do exactly what you ask. About the only way would be to configure IIS -- for the virtual domains being served by IIS -- to forward to Apache on port 81. With this configuration, the client would not be aware that their requests were passing through IIS on their way to Apache. A little less efficient, but it would solve your needs.

绿光 2024-07-18 20:16:31

当输入 URL 时,浏览器必须使用某个端口来连接到该站点。 80 是服务器检查的默认端口。 如果您需要通过浏览器连接到任何其他端口,则需要在 url 中包含端口号。 不是 apache 强迫您输入 81,而是您的浏览器,因为在未指定端口号时它被设置为使用 80 作为端口。

如果您将 apache 的端口更改为 80,将 IIS 端口更改为 81,则无需端口号即可连接到 apache,但在使用 IIS Web 服务器时需要使用端口号。

不确定使用 apache 重定向到 IIS 的其他人的想法是什么。 在我看来,如果您在 apache 的 httpd.conf 中为 IIS 目录创建一个条目,那么您将使用 apache 连接到该目录,而不是 IIS。
您可以设置一个域并让它通过端口 81 连接到 apache。这是隐藏端口号的一种方法(可能不是真的。我从未在 80 以外的端口上尝试过 apache)。

When an url is typed, there is a certain port that the browser has to use to connect to the site. 80 is the default port that the server checks. If you need to connect to any other port via a browser, you would need to have the port number in the url. It is not apache that is forcing you to type 81, but rather your browser because it is set to use 80 as the port when a port number is not specified.

If you were to change apache's port to 80 and IIS port to 81, then you be able to connect to apache without the port number but you will need to use the port number when using the IIS webserver.

Not sure what the others idea is behind using apache to redirect to IIS. It sounds like to me that if you make an entry in httpd.conf of apache for IIS directory, then you be using apache to connect to the directory, not IIS.
You could set up a domain and have it connect to apache via port 81. That is one way to hide the port number (might be not true. I have never tried apache on port other than 80).

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