As I cannot access to ports other than 80 and 443 at work, I would like to make accessible some resources using Apache on my QNAP.
In particular I would like to:
- set a Virtual Host (using sub1.domain.com) to connect to a service running on the same host (my QNAP) (http://localhost:58000)
- set a Virtual Host (using sub2.domain.com) to connect to another host within the LAN (http://192.168.1.1:78080)
- set a Virtual Host (using sub3.domain.com) to connect to an external website (e.g. https://www.google.com)
Beside activating proxy_module and proxy_ssl_module (and changing DNS accordingly), I have thought to use the following line codes on httpd-vhosts-user.conf (for 1. and 2.) and on httpd-ssl-vhosts-user.conf (for 3.):
General sections (FYI):
/etc/config/apache/extra/httpd-vhosts-user.conf
NameVirtualHost *:80
<VirtualHost _default_:80>
DocumentRoot "/share/Web"
</VirtualHost>
/etc/config/apache/extra/httpd-ssl-vhosts-user.conf
NameVirtualHost *:443
<VirtualHost _default_:443>
DocumentRoot "/share/Web"
</VirtualHost>
Virtual Host to connect to the service running on http://localhost:58000
<VirtualHost *:80> ServerName sub1.domain.com DocumentRoot "/share/Web/sub1" ProxyPreserveHost On ProxyRequests Off ProxyVia Off ProxyPass /sub1 http://localhost:58000 ProxyHTMLURLMap http://localhost:58000 /sub1 <Location /sub1> ProxyPassReverse / ProxyHTMLInterp On ProxyHTMLURLMap / /sub1 RequestHeader unset Accept-Encoding </Location> <Proxy *> AddDefaultCharset off Order deny,allow Deny from all Allow from all </Proxy> <Directory "/share/Web/sub1"> Options FollowSymLinks MultiViews Order allow,deny Allow from all </Directory> </VirtualHost>
Virtual Host to connect to other service running on http://192.168.1.1:78080
<VirtualHost *:80> ServerName sub2.domain.com DocumentRoot "/share/Web/sub2" ProxyPreserveHost On ProxyRequests Off ProxyVia Off ProxyPass /sub2 http://192.168.1.1:78080 ProxyHTMLURLMap http://192.168.1.1:78080 /sub2 <Location /Asus> ProxyPassReverse / ProxyHTMLInterp On ProxyHTMLURLMap / /sub2 RequestHeader unset Accept-Encoding </Location> <Proxy *> AddDefaultCharset off Order deny,allow Deny from all Allow from all </Proxy> <Directory "/share/Web/sub2"> Options FollowSymLinks MultiViews Order allow,deny Allow from all </Directory> </VirtualHost>
Virtual Host to connect to the given external site (e.g. google) [credits to kamal @ serverfault.com]
<VirtualHost *:443> ServerName sub3.domain.com ProxyPreserveHost On <Proxy *> AddDefaultCharset off Order deny,allow Deny from all Allow from all </Proxy> ProxyPass /sub3 https://www.google.com/ ProxyHTMLURLMap https://www.google.com /sub3 <Location /sub3> ProxyPassReverse / ProxyHTMLInterp On ProxyHTMLURLMap / /sub3 RequestHeader unset Accept-Encoding </Location> </VirtualHost>
However none of these Virtual Hosts work (I have a connection fail or endless loading).
Could someone please help me reviewing the code?
Thank you very much in advance!