Apache2 反向代理多个服务器?

huangapple go评论46阅读模式
英文:

Apache2 reverse proxy from multiple servers?

问题

以下是要翻译的部分:

"Is it possible to display the webpage of the 2nd and 3rd web server via an iframe off the first main device webpage? I first thought I could do a reverse proxy but, when I followed guides on the internet, I could get the iframe to only display off the main webserver page when the client device was on the local network, otherwise it looks like the iframe is trying to connect to the ip address of the 2nd and 3rd device which is not exposed to the internet.

Would a reverse proxy be able to achieve this without exposing the other 2 devices directly to the web and I just didn't set it up correctly? Is there another way to do this or just deal with this limitation?

Thank you!

I tried setting up a reverse proxy from this guide: https://www.digitalocean.com/community/tutorials/how-to-use-apache-as-a-reverse-proxy-with-mod_proxy-on-ubuntu-16-04 and https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension"

英文:

I am trying to make something work but I am not sure it is even possible. Here is the rundown on the devices I have connected.

Main linux webserver - Authenticated website, controls some things, ran on device 1, IP address exposed to the internet.

2nd linux webserver - Accessed on local network only, device controls different things than the 1st. Ran on device 2.

3rd linux webserver - Once again, accessed on local network only, device controls different things than the 1st and 2nd. Ran on device 3.

Is it possible to display the webpage of the 2nd and 3rd web server via an iframe off the first main device webpage? I first thought I could do a reverse proxy but, when I followed guides on the internet, I could get the iframe to only display off the main webserver page when the client device was on the local network, otherwise it looks like the iframe is trying to connect to the ip address of the 2nd and 3rd device which is not exposed to the internet.

Would a reverse proxy be able to achieve this without exposing the other 2 devices directly to the web and I just didn't set it up correctly? Is there another way to do this or just deal with this limitation?

Thank you!

I tried setting up a reverse proxy from this guide: https://www.digitalocean.com/community/tutorials/how-to-use-apache-as-a-reverse-proxy-with-mod_proxy-on-ubuntu-16-04 and https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension

答案1

得分: 0

'Main linux webserver' 必须能够 ping 另外两台服务器。
另外两台本地服务器有唯一的 IP 地址 - 对吗?
在另外两台本地服务器上,你可以使用 Apache 来提供网页。
然后 'Main linux webserver' 可以请求另外两台服务器的 URL 页面,将页面嵌套到 iframes 中。

英文:

'Main linux webserver' must be able to ping the other two servers.
The other two local servers have a unique IP address - right?
On the other two local servers you could have apache serving up web pages.
Then 'Main linux webserver' can then request the URL pages from other two servers to get the pages into iframes.

答案2

得分: 0

我通过编辑 Apache 服务器的 .conf 文件,并为另外两个 Web 服务器的每个添加以下内容,最终使其工作起来:

<Proxy *>
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Proxy>
<Location /site/>
Allow from all
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set expire 0
ProxyPass "http://192.168.0.34/site/"
ProxyPassReverse "http://192.168.0.34/site/"
</Location>
英文:

I ended up getting it to work by editing the .conf file for the apache server and adding this to the end for each of the other 2 webservers.

<Proxy *>
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Proxy>
<Location /site/>
Allow from all
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set expire 0
ProxyPass "http://192.168.0.34/site/"
ProxyPassReverse "http://192.168.0.34/site/"
</Location>

huangapple
  • 本文由 发表于 2023年2月18日 03:06:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75488363.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定