大网数据广告活动
服务器运维问答

how do I forward by hostname to different web hosts behind a firewall --mod_proxy?

· 52CE 我爱测

I need a quick solution that allows me to host multiple web servers behind my firewall. They are on different computers, so I can't use apache virtual hosting. I also don't want to use different non-standard ports for each machin…

问题原文

原帖链接 · ajnabi · CC BY-SA 3.0

I need a quick solution that allows me to host multiple web servers behind my firewall. They are on different computers, so I can't use apache virtual hosting. I also don't want to use different non-standard ports for each machine.

The problem is my router can only forward port 443 to one machine. I thought the best solution would be to use reverse proxy or proxy forwarding, but I have been having problems understanding how to set this up.

  • I am assuming that I can port forward all 443 traffic to one of the servers and make that the proxy server.
  • All servers accept htmls traffic only.
  • I am using DDNS and all the servers resolve to the same WAN IP address.

Setup:

  • server1.domain.com = proxy and wiki server
  • server2.domain.com = documentation server
  • server3.domain.com = owncloud server

I tried putting the following in /etc/apache2/conf-available/proxy-pass.conf on server1:

SSLProxyEngine on
ProxyPass "/directory"  "https://server2.domain.com/directory" 
ProxyPass "/owncloud"  "https://server3.domain.com/owncloud" 

This works but it's not what I am looking for.

I need to direct all traffic to the server designated by the incoming URL domain name regardless of the directory because I have a lot of subdirectories after the base URL.

Something like:

ProxyPass "https://server2.domain.com"  "https://server2.domain.com" 
ProxyPass "https://server3.domain.com"  "https://server3.domain.com"

Should I be looking to another solution, such as pound, or is there a way of doing this with apache. I figured I have apache installed, so use it?

已采纳解答

原帖链接 · HBruijn · CC BY-SA 3.0

They are on different computers, so I can't use apache virtual hosting

Actually that's is exactly what you need to do ;)

The manual is not explicit about it, but you reverse proxy everything for a specific host by making / , the root URL, the target for the ProxyPass directive in a virtual host entry:

<VirtualHost *:80>
  ServerName host.example.com
  ProxyPass / http://internalserver.example.net/
  ProxyPassReverse / http://internalserver.example.net/
</VirtualHost>
<VirtualHost *:80>
  ServerName host2.example.com
  ProxyPass / http://other-internalserver.example.net/
  ProxyPassReverse / http://other-internalserver.example.net/
</VirtualHost>

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-09-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。