Reverse proxy and mod_proxy_html

Post your questions about Web Server usage and Apache + PHP + MySQL/SQLite web applications.

Reverse proxy and mod_proxy_html

Postby rowanmoor » Tue Mar 02, 2010 10:00 pm

Hi,

I have been experimenting with using apache on my QNAP (210) as a reverse proxy for a couple of things. At a basic level it works fine. mod_proxy and mod_proxy_http are present and work ok.

However, I got to the point where I needed to use mod_proxy_html to rewrite links in the target web sites. It seems that this is not present in the modules folder.

Is there anywhere I can get a suitable compiled mod_proxy_html that will work?
Am I the only one, or would it make a sensible feature request for future firmwares? I am guessing things like this give a size issue for the firmware updates.

Has anyone worked round this in other ways?
It seems a bit silly to me to use a seperate reverse proxy app when Apache is sitting there running and capable of it, but I guess I would consider other apps.

I have seen mention of using a second apache from ipkg which has all the modules available. I guess that is an option, but again it seems a bit silly to do that when apache is already sitting there working fine up to a point. Are the modules from the ipkg apache compatible with the inbuilt apache or will I get version problems if I try that?

Cheers,
Rowan.
TS-210, firmware 3.2.3 Build 0212T
rowanmoor
New here
 
Posts: 3
Joined: Wed Nov 18, 2009 9:31 pm
NAS Model: TS-219P

Re: Reverse proxy and mod_proxy_html

Postby snelvuur » Fri Apr 02, 2010 9:15 pm

I too want mod_proxy_http, this will allow me to run my slimserver on say http://<ip>/slimserver thus not needing strange ports in the url, which most corperate proxy's use for instance. Also looks much nicer to have that. Same for sabnzbd, http://<ip>/sabnzbd/ not to mention all other equipment that needs a way in from the outside.

Checked the forum too, i can only see that QNAPAndy did some mod_rewrite module at some point, perhaps he has the knowledge to build a mod_proxy_http in a similar way. I am running on the 809 pro, but basicly that should not matter that much i presume.

I have a spare system running with asterisk, where i can put a fully blown apache on, but like you said too.. this would be so much nicer. If i could get this fixed i might even move asterisk too and turn of that asterisk system (although its only a vmware one, it still consumes footprint on my server:)
snelvuur
Starting out
 
Posts: 21
Joined: Fri Dec 11, 2009 4:52 am
Location: Netherlands
NAS Model: TS-639U

Re: Reverse proxy and mod_proxy_html

Postby enterinner » Sun May 23, 2010 3:31 am

Hi all,

New to the forum but wanted to get exactly the same feature for my slimserver.

Having done some research I came up with the following process to generate the mod_proxy_html shared object. Note also needed mod_xml2enc for some of the functionality.

I tested this on a ts-639 and Firmware version 3.2.4 Build 0315T and it works for me but there are no guarantees that it will work for you.

Basically you will need the following installed:
    ipkg
    bash
    libxml2
I may have other stuff installed but that would be back in the history of the NAS. Had it for 9 months...

So to deal with the ipkg stuff I will assume that you have already installed ipkg through the gui:
Logon to the NAS box
Code: Select all
ipkg install bash
ipkg install libxml2


Then you need to setup some directories and some links. This is what I did but the directories can be changed to a suitable location on your NAS:
Code: Select all
## link bash so that apxs can find it.
ln -s /opt/bin/bash /bin/bash

## setup area to enable the apxs and libtool to run successfully,
## looks like the apxs that is installed by default has development paths in it so these tweak the system to allow the command to run
mkdir /share/MD0_DATA/tmp
ln -s /share/MD0_DATA/tmp /root/daily_build
cd /share/MD0_DATA/tmp
mkdir -p 0110branch/Model/TS-259/../../NasMgmt/HTTP
cd 0110branch/Model/TS-259/../../NasMgmt/HTTP
ln -s /usr/local/apache apache_install_tmp
ln -s /share/MD0_DATA/tmp /opt/cross-project
cd /share/MD0_DATA/tmp/
mkdir -p x86/sys-root
cd x86/sys-root
ln -s /bin bin

Note: I left these in place once completed and it works for me. I did have a problem with the sys-root originally in that the apache would not start but I changed the depth of the final link to be bin rather than sys-root which fixed the problem.

The next stage is to get the Apache module source I would recommend using the above tempory directory for this so as not to fill the root partition.
Code: Select all
## get apache module
cd /share/MD0_DATA/tmp
wget http://apache.webthing.com/mod_proxy_html/mod_proxy_html.tar.bz2
bzip2 -d mod_proxy_html.tar.bz2
tar xvf mod_proxy_html.tar

cd mod_proxy_html
cp proxy_html.conf /usr/local/apache/conf/extra

Note: Not sure if bzip2 is part of the core NAS build or an ipkg. I will leave that up to you to find out but if it needs to be installed it would be ipkg install bzip2 at a guess.

Next we need to compile the Apache module.

Code: Select all
## compile module
cd /share/MD0_DATA/tmp
/opt/bin/perl /usr/local/apache/bin/apxs -I/opt/include/libxml2/libxml -I/usr/local/apache/include -I. -i -c mod_proxy_html.c
/opt/bin/perl /usr/local/apache/bin/apxs -I/opt/include/libxml2/libxml -I/usr/local/apache/include -I. -i -c mod_xml2enc.c

Note: This will put the module in /usr/local/apache/module

That is it with regards to the getting the module compiled you would have to add the relevant config files to apache config. I note that you wanted to get slimserver running as a reverse proxy. In order to do that I had to make the following amendments to the proxy_html.conf file:
Uncomment the following lines:
    ProxyHTMLLinks frame src longdesc
    ProxyHTMLLinks iframe src longdesc
    ProxyHTMLLinks body background
    ProxyHTMLLinks applet codebase

I also had limited success in getting slimserver to work with the new Default skins and had to switch to the Classic skin. I think this is due to the js files not being passed properly but I am happy with the classic look.
This is my config file (/usr/local/apache/conf/extra/slimserver.conf):
Code: Select all
## load all stuff that is required
Include /etc/config/apache/extra/proxy_html.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule headers_module modules/mod_headers.so
LoadFile   /usr/lib/libxml2.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule xml2enc_module modules/mod_xml2enc.so

# Slimserver Reverse Proxy Configuration
# Prepared by BV January 2008
#
# Make sure that the server cannot be abused
ProxyRequests Off
#ProxyHTMLLogVerbose On

# The Proxy section below allows internet users
# to access the internal server
  #ProxyHTMLExtended On
ProxyPass /slimserver/ http://localhost:9001/
ProxyHTMLURLMap http://localhost:9001 /slimserver
ProxyPass /jsonrpc.js http://localhost:9001/
ProxyHTMLURLMap http://localhost:9001 /jsonrpc.js
ProxyPass /html/ http://localhost:9001/
ProxyHTMLURLMap http://localhost:9001 /html

<Location /slimserver/>
  ProxyPassReverse /
  ProxyHTMLEnable On
    ProxyHTMLURLMap / /slimserver/
    RequestHeader unset Accept-Encoding
</Location>

You will need an Include entry in the /usr/local/apache/conf/apache.conf file to source this file.

All being well this should work and if anybody manages to get the Default skin to work I would be very interested how this was performed.

Dave
enterinner
New here
 
Posts: 2
Joined: Sun May 23, 2010 3:04 am
Location: Warwickshire, UK
NAS Model: TS-509 Pro

Re: Reverse proxy and mod_proxy_html

Postby enterinner » Tue May 25, 2010 3:07 am

Also note that the URL will need to be http://<server>/slimserver/ The trailing / is important.

If you add the following lines to the slimserver.conf file you will be able to use http://<server>/slimserver

## additional to redirect /slimserver to /slimserver/
Redirect permanent /slimserver /slimserver/
enterinner
New here
 
Posts: 2
Joined: Sun May 23, 2010 3:04 am
Location: Warwickshire, UK
NAS Model: TS-509 Pro

Re: Reverse proxy and mod_proxy_html

Postby DeDi » Thu Oct 21, 2010 10:20 pm

Thank you!

I managed to compile it for my 259-pro+, only a few paths were different.

Now I can access my links without the port number:

http://QNAP/sabnzbd
http://QNAP/sickbeard
DeDi
First post
 
Posts: 1
Joined: Fri Oct 15, 2010 5:53 pm
NAS Model: TS-459U

Re: Reverse proxy and mod_proxy_html

Postby schumaku » Fri Oct 22, 2010 7:36 am

No need to compile anything - everything required is readily available, here on v3.3.4:

[~] # ls -ls /mnt/ext/opt/apache/modules/mod_proxy*
76 -rwxr-xr-x 1 admin administ 70084 Oct 18 18:32 /mnt/ext/opt/apache/modules/mod_proxy.so*
36 -rwxr-xr-x 1 admin administ 33680 Oct 18 18:32 /mnt/ext/opt/apache/modules/mod_proxy_ajp.so*
24 -rwxr-xr-x 1 admin administ 23108 Oct 18 18:32 /mnt/ext/opt/apache/modules/mod_proxy_balancer.so*
8 -rwxr-xr-x 1 admin administ 7928 Oct 18 18:32 /mnt/ext/opt/apache/modules/mod_proxy_connect.so*
32 -rwxr-xr-x 1 admin administ 30904 Oct 18 18:32 /mnt/ext/opt/apache/modules/mod_proxy_ftp.so*
32 -rwxr-xr-x 1 admin administ 29964 Oct 18 18:32 /mnt/ext/opt/apache/modules/mod_proxy_http.so*
12 -rwxr-xr-x 1 admin administ 11972 Oct 18 18:32 /mnt/ext/opt/apache/modules/mod_proxy_scgi.so*

Enjoy,
-Kurt.
User avatar
schumaku
Guru
 
Posts: 29597
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
NAS Model: TS-x79 Pro

Re: Reverse proxy and mod_proxy_html

Postby danirod » Thu Dec 16, 2010 4:29 pm

Nope, unfortunately mod_proxy_html is not available, not in the preinstalled Apache nor on the IPKG package therefore needs to be compiled, at least for Arm-based NASes.
I've tried to compile it myself on my TS-110 with no luck as all paths on the apxs and config_vars.mk are messed up and there are quite a few *.h missing (particularly the ones related to APR) and whatnot so until some kind soul provides it we're pretty much stuck.
I even thought trying to cross-compile it on a virtual Linux instance but I think it's beyong my Linux hacking skills... :?

Anyone has managed to do this?

Cheers
danirod
Starting out
 
Posts: 33
Joined: Mon Nov 15, 2010 6:33 pm
Location: Spain
NAS Model: TS-110

Re: Reverse proxy and mod_proxy_html

Postby czechplease » Tue Mar 01, 2011 3:31 pm

Would it be possible to post the *.so files so that others using x86-based NASes can use them?
czechplease
Starting out
 
Posts: 18
Joined: Fri May 09, 2008 1:36 pm
NAS Model: TS-259 Pro+

Re: Reverse proxy and mod_proxy_html

Postby lmolenaar » Wed Aug 15, 2012 9:38 pm

Hi enterinner!

I am trying to compile the mod_proxy_html according to your guide (thanks for that!) but encounter a problem. Perhaps it makes more sense to you and you could give me a pointer?

[/share/MD0_DATA/tmp] # /opt/bin/perl /usr/local/apache/bin/apxs -I/opt/include/libxml2/libxml -I/usr/local/apache/include -I. -i -c mod_proxy_html.c
Code: Select all
cannot open /root/daily_build/3.7.x/Model/TS-459/../../NasMgmt/HTTP/apache_install_tmp/build/config_vars.mk: No such file or directory at /usr/local/apache/bin/apxs line 219.

I already tried changing the "TS-259" string referenced in your instructions with "TS-459" as mentioned in the error message, to no avail (both do not make sense to me as I own a 509-pro :? ).

[~/daily_build] # pwd
Code: Select all
/root/daily_build

[~/daily_build] # ls -al
Code: Select all
drwxr-xr-x    5 admin    administ     4096 Aug 15 15:17 ./
drwxrwxrwx   30 admin    administ     4096 Aug 15 15:01 ../
drwxr-xr-x    4 admin    administ     4096 Aug 15 15:03 0110branch/
drwxr-xr-x    2 101      10           4096 Oct 30  2009 mod_proxy_html/
-rw-r--r--    1 admin    administ    92160 Oct 30  2009 mod_proxy_html.tar
lrwxrwxrwx    1 admin    administ       19 Aug 15 15:17 tmp -> /share/MD0_DATA/tmp/
drwxr-xr-x    3 admin    administ     4096 Aug 15 15:03 x86/

I see the /root/daily_build/3.7.x/.. directories are missing. Which step did I miss to make it available?
100Mb WAN <--> Asus RT-N56u <--> TS-509 Pro ultra (E7500, 4GB, 5x 3TB Seagate)
(Optware/Pure-ftpd/SSOT/SABNZBd/Sickbeard/Couchpotato)
What seems to be the officer problem?
lmolenaar
Know my way around
 
Posts: 164
Joined: Mon May 19, 2008 4:34 pm
Location: Geldrop
NAS Model: TS-509 Pro

Re: Reverse proxy and mod_proxy_html

Postby forkless » Wed Aug 15, 2012 11:22 pm

It's missing the Apache apxs utility, which should be available in the Optware repository, however I'm not sure if that version is compatible. I didn't think it was so I had to recompile Apache from source to get it. (I got stuck compiling some other bits after that myself).

Hope that helps.
TS-219P+ II, Firmware 4.1.0 Build 20131024
TS-809 PRO, Firmware 4.1.0 Build 20131024

- Why can't I connect to my website and what is this NAT loopback business?
- 64bit benchmark utility NASPTv1.7.1
[SHA1] 6ec4e58b14a9f1dd96f3775e43757ee17086c7d8
- Maintaining phpMyAdmin / UnrealIRCd / SpotWeb / XDM
User avatar
forkless
Experience counts
 
Posts: 1387
Joined: Mon Nov 23, 2009 6:52 am
Location: The Netherlands
NAS Model: TS-809 Pro

Re: Reverse proxy and mod_proxy_html

Postby lmolenaar » Wed Aug 15, 2012 11:41 pm

forkless wrote:It's missing the Apache apxs utility, which should be available in the Optware repository, however I'm not sure if that version is compatible. I didn't think it was so I had to recompile Apache from source to get it. (I got stuck compiling some other bits after that myself).

Hope that helps.

Not sure if that is the case:
[/share/MD0_DATA/tmp] # cd /usr/local/apache/bin/
[/usr/local/apache/bin] # ls
Code: Select all
ab*           apachectl*    apu-1-config* checkgid*     envvars       htcacheclean* htdigest*     httxt2dbm*    php*          rotatelogs*
apache*       apr-1-config* apxs*         dbmmanage*    envvars-std   htdbm*        htpasswd*     logresolve*   pwauth*

apxs is there it seems..
100Mb WAN <--> Asus RT-N56u <--> TS-509 Pro ultra (E7500, 4GB, 5x 3TB Seagate)
(Optware/Pure-ftpd/SSOT/SABNZBd/Sickbeard/Couchpotato)
What seems to be the officer problem?
lmolenaar
Know my way around
 
Posts: 164
Joined: Mon May 19, 2008 4:34 pm
Location: Geldrop
NAS Model: TS-509 Pro

Re: Reverse proxy and mod_proxy_html

Postby phreichmuth » Thu Jul 18, 2013 4:59 am

@enterninner: What do you mean in the paths in your guide? What do the dots /../../ replace? How does your actual path look like?

Code: Select all
/share/MD0_DATA/tmp/0110branch/Model/TS-259/../../NasMgmt/HTTP


Or can someone else advise me?
TS-219P+, firmware QTS-4.0.2
wiki.makeitfit.ch
phreichmuth
Know my way around
 
Posts: 173
Joined: Fri Jan 09, 2009 12:17 am
NAS Model: TS-219P+

Re: Reverse proxy and mod_proxy_html

Postby wolf27 » Thu Aug 01, 2013 8:09 pm

Hi,

It's the missing file "build/config_vars.mk", I've been running into the same troubles.
Is there any idea how to get it?

Update: Update to Firmware 4.0.2 but nothing changes for this topic.
To be honest I want to avoid recompiling the whole apache - only to the the configs which those it has been compiled...
- Wolfgang
wolf27
New here
 
Posts: 2
Joined: Thu Aug 01, 2013 8:04 pm
NAS Model: TS-x20


Return to Web Server & Applications (Apache + PHP + MySQL / SQLite)

Who is online

Users browsing this forum: No registered users and 3 guests