I've got a raspberry pi working and being accessible through a domain, which is asada.net. It serves web pages using apache 2.2.22.
Besides, I recently bought a NAS which has a web page in a local apache instance (embedded), too.
Raspberry pi's local ip is 192.168.0.4 and NAS's local ip is 192.168.0.5.
Every time I access www.asada.net, raspberry pi's root page is shown.
Now, what I want to do is to redirect www.asada.net/nas to the NAS's ip, 192.168.0.5, so that this page gets accessible from outside.
I don't want asada.net to point to 192.168.0.5 nor making any changes to its apache server, just redirect it from raspberry pi.
So every configuration I've tried has been made in raspberry pi's apache. I've enabled mod_proxy; tried ProxyPass and ProxyPassReverse, I've also tried Location directive... But with no luck.
Could anybody help me out?
Thanks in advance!
EDIT: My raspberry pi is running Raspbian and apache's version is 2.2.22. These are loaded modules:
Loaded Modules:
core_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
alias_module (shared)
auth_basic_module (shared)
authn_file_module (shared)
authz_default_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cgi_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
headers_module (shared)
mime_module (shared)
negotiation_module (shared)
php5_module (shared)
proxy_module (shared)
proxy_ajp_module (shared)
proxy_balancer_module (shared)
proxy_connect_module (shared)
proxy_ftp_module (shared)
proxy_html_module (shared)
proxy_http_module (shared)
proxy_scgi_module (shared)
reqtimeout_module (shared)
rewrite_module (shared)
setenvif_module (shared)
status_module (shared)
Syntax OK
EDIT 2: I've been able to make some progresses. This is my VirtualHost:
<VirtualHost *:80>
ServerAdmin mymail@gmail.com
ServerName asada.net
ServerAlias www.asada.net
DocumentRoot /var/www
# NAS
ProxyPreserveHost on
ProxyPass /nas http://192.168.0.5
ProxyPassReverse /nas http://192.168.0.5
</VirtualHost>
Now, it somehow works... Web pages are loaded, but resources aren't. Let me post an screenshot:
What can I do?
EDIT 3: Mate @Froggiz suggested me here some ways to achieve my goal, so I choosed what I thought it'd fit best my requirements: URL mapping. I discarded subdomains as my domain is free (noip.com).
Currently, my VirtualHost looks like the following piece of code:
<VirtualHost *:80>
ServerAdmin mymail@gmail.com
ServerName asada.net
ServerAlias www.asada.net
DocumentRoot /var/www
# NAS
ProxyPreserveHost on
ProxyPass /nas http://192.168.0.5
ProxyPassReverse /nas http://192.168.0.5
ProxyHTMLURLMap http://192.168.0.5 /nas
<Location /nas>
ProxyPassReverse /
SetOutputFilter proxy-html
ProxyHTMLURLMap http://192.168.0.5 /nas
ProxyHTMLURLMap / /nas
ProxyHTMLURLMap /nas /nas
RequestHeader unset Accept-Encoding
</Location>
</VirtualHost>
Everything seem to be correctly setup. When I type asada.net/nas on my browser, the typical broken image is shown on the page:
And in the debugging console the is something weird: every resource which should be loaded gets a 'Failed to load resource: the server responded with a status of 404 (Not Found)' error. What's more weird is that the link of the resource (placed on the right) seems to be missing an '/' just after '...net/nas' and before 'web/...':
Look, my guess is that it should be
instead.
Any thoughts? Thank you again.