Is it possible for a RPi server to serve from another RPi on the same network?
I have 2 RPi's on my home network, both running apache servers - Raspberry A is linked to a web domain i.e. mydomain.net
, and the router redirects incoming http/https calls to it; Raspberry B is only available inside the network at network IP 192.168.1.123
. If possible I'd like to create a html/php page on Raspberry A that relays calls to/from Raspberry B's network IP. Grateful for any advice on how to achieve this.
-
IHMO - no simple way -try to read this... docs.trafficserver.apache.org/en/4.2.x/admin/… However, I would create a simple python webserver on B that - each call - would make a call to A and copied the response.jaromrax– jaromrax2017年02月06日 16:54:05 +00:00Commented Feb 6, 2017 at 16:54
1 Answer 1
You are talking about a reverse proxy. The apache docs explain it in detail here : https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html
Essentially, you need mod_proxy
enabled and then you can use the ProxyPass directive.
Example (from the docs):
ProxyPass "/images" "http://www.example.com/"
ProxyPassReverse "/images" "http://www.example.com/"
In the above, any requests which start with the /images path with be proxied to the specified backend, otherwise it will be handled locally.
Note: The ProxyPassReverse
is used to make sure that the displayed URLs that make it back to the client are for the proxy not the (unreachable directly) back end server.
-
Just picking this up again. The guidance seems to leave quite a bit inferred. Where is this example supposed to go - /etc/apache2/apache2.conf? Inside directory tags? Do I need to create a directory in web path to link the setting to? Does it need to include anything? I'm probably over-complicating it, but this documentation does seem light..geotheory– geotheory2017年02月22日 01:35:57 +00:00Commented Feb 22, 2017 at 1:35
-
In
sites-available/default
(or the.conf
file for the particular site, if you're hosting multiple) inside the <VirtualHost> element create a <Location> element and add the two directive above inside that.KennetRunner– KennetRunner2017年02月22日 08:59:55 +00:00Commented Feb 22, 2017 at 8:59