Installing Mod-Proxy-Html and Proxying Virtuoso Via Apache2
2011-02-12 20:07
1031 查看
Contents
[hide] 1 Introduction 2 Installing Mod-Proxy-Html on Ubuntu 3 Installing Mod-Proxy-Html on any Linux Distribution 4 Configuring Apache2 For Proxying Virtuoso Queries 5 ReferencesIntroduction
Sometimes it may not be possible to access the Virtuoso back-end (such as its Conductor or SPARQL user interface) via its default port 8890. There exists setups where you only have the HTTP and SSH ports open, and that you can't do otherwise. However, you have to have Apache2 running on port 80, and you have to have Virtuoso running on another port (let's say: 8890). In that case, you have to proxy all Virtuoso queries via Apache2 using mod-proxy and mod-proxy-html. For this tutorial, we consider that all basic Linux distributions have installation packages for Apache2 that includes mod-proxy by default. If it is not the case, you will have to install mod-proxy first. This tutorial is about installing mod-proxy-html only, and to configure mod-proxy and mod-proxy-html for proxying Virtuoso queries via Apache2.Installing Mod-Proxy-Html on Ubuntu
Installing mod-proxy-html on Ubuntu is as simple as running this apt-get installation command: apt-get install libapache2-mod-proxy-html ------------------- 配置: 1.加载模块:sudo a2enmod proxy sudo a2enmod proxy_html
2. 开启代理功能:
sudo vim /etc/apache2/mods-enabled/proxy.conf - change to: AddDefaultCharset off #Order deny,allow #Deny from all #Allow from .example.com Order allow,deny Allow from all - warning: you might want to restrict that a little to your networks
3.例子:
sudo apt-get install libapache2-mod-proxy-html
sudo a2enmod proxy sudo a2enmod proxy_html
sudo vim /etc/apache2/mods-enabled/proxy.conf - change to: AddDefaultCharset off #Order deny,allow #Deny from all #Allow from .example.com Order allow,deny Allow from all - warning: you might want to restrict that a little to your networks
sudo vim /etc/apache2/sites-enabled/000-default
- Under put some forwarding parameters e.g.:
ProxyPass /instance1 http://172.19.1.2
sudo /etc/init.d/apache2 reload
Navigate to http://cc/instance1 and you should be redirected to web server running on instance at private address 172.19.1.2 (change the rule to match your instance address and make sure it's running a webserver!)
-----------------------------------------------------------------------------
Installing Mod-Proxy-Html on any Linux Distribution
In this case, we have a Linux distribution which has a pre-packaged version of Apache2 that comes with mod-proxy, but that doesn't come with mod-proxy-html. It is the case with CentOS 5 for example.In that case, you have no other choices than downloading the source, and to compile it.
First, go to the temp folder of your distribution:
cd /tmp
Then download the mod-proxy-html source codes:
wget http://apache.webthing.com/mod_proxy_html/mod_proxy_html.zip Then unzip the source:
unzip mod_proxy_html.zip
cd mod_proxy_html
Then you have to make sure you have the libxml2 development toolkit installed on your system. The library is installed on any Linux distribution, but not the developer toolkit. Lets consider that you have access to the libxml2-devel RPM package and YUM:
yum install libxml2-devel
Then the next step is to make sure that you have the apache2 developer toolkit installed on your server as well. We need the apxs software to compile the module. Lets install it:
yum install httpd-devel
Then the next step is to compile the mod-proxy-html and the mod-xml2enc modules:
apxs -c -I/usr/include/libxml2 -I. -i mod_proxy_html.c
apxs -c -I/usr/include/libxml2 -I. -i mod_xml2enc.c
The apxs application will compile the module and will install it into the modules folder of your Apache2 server.
-----------------------
配置:
Add necessary directives in httpd.conf:
LoadFile /usr/lib/libxml2.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule mod_xml2enc modules/mod_xml2enc.so
然后: service httpd restart 即可。
--------------------------------------------
-----------------------------------------------------
Configuring Apache2 For Proxying Virtuoso Queries
Now is the time to configure Apache2 to proxy Virtuoso queries. A simple configuration file for Apache2 looks like:# Disable global proxy ProxyRequests Off # Pass original host to Virtuoso ProxyPreserveHost On # Timeout waiting for Virtuoso ProxyTimeout 300 # Set permission Order deny,allow Allow from all #ProxyHTMLLogVerbose On #LogLevel Info #LogLevel Debug # Configuring the links that will be re-written ProxyHTMLLinks a href ProxyHTMLLinks area href ProxyHTMLLinks link href ProxyHTMLLinks img src longdesc usemap ProxyHTMLLinks object classid codebase data usemap ProxyHTMLLinks q cite ProxyHTMLLinks blockquote cite ProxyHTMLLinks ins cite ProxyHTMLLinks del cite ProxyHTMLLinks form action ProxyHTMLLinks input src usemap ProxyHTMLLinks head profile ProxyHTMLLinks base href ProxyHTMLLinks script src for ProxyHTMLEvents onclick ondblclick onmousedown onmouseup / onmouseover onmousemove onmouseout onkeypress / onkeydown onkeyup onfocus onblur onload / onunload onsubmit onreset onselect onchange # Defining the URLs to proxy ProxyPass http://localhost:8890/ ProxyPassReverse / ProxyHTMLEnable On ProxyHTMLURLMap / /virtuoso/ ProxyHTMLURLMap http://localhost:8890/ /virtuoso/
What it does is to forward any queries has a URL of the form: "http://mydomain.com/virtuoso/", into a query to the virtuoso server located at: "http://localhost:8890/". Then it will return the results to the user.
What is important here is the mod-proxy-html module. What it does is to make sure that if you click on a link, within the web page, that this links refers to the same server as well. So, what this module does is really to rewrite the links within the HTML web page that is proxied such that they are consistent according to the ProxyHTMLURLMap rules.
References
http://apache.webthing.com/mod_proxy_html/http://www.apachetutor.org/admin/reverseproxies
http://docs.openlinksw.com/virtuoso/webserver.html
相关文章推荐
- HTTP Proxy Servers and Proxying
- Working with Characters and Strings(Chapter 2 of Windows Via C/C++)
- HTMLParser — Simple HTML and XHTML parser
- Zp的Ext学习笔记(一)——坑爹的MVC(html中Extjs配置、proxy代理的前后台交互、json解析、后台处理传入json乱码)
- What is the relationship between the From, Contact, Via and Record-Route/Route headers?
- Abandoned Object Detection via Temporal Consistency Modeling and Back-Tracing Verification for Visua
- Head first HTML and CSS 总结-1.HTML简介
- Ubuntu服务器下apache2无法解析html中的php代码的问题
- Great Html Tab Panel Using CSS and Javascript
- GPUDirect and DirectGMA – direct GPU-GPU communication via RDMA
- Head first HTML and CSS 总结-5.网页中的图像
- Web(click and script) 与 Web(HTTP/HTML)协议区别
- Dynamic Proxy、 Proxy Pattern and Decorator Pattern
- 【HTML】Intermediate4:Tables:rowspan and colspan
- Create intelligent Web spiders -How to use Java network objects and HTML objects
- 《Scalable and Sustainable Deep Learning via Randomized Hashing》 阅读报告
- [Note]CLR via C#3-Event and Delegate
- 【HTML】Advanced7:HTML5 Forms Pt. 2: Attributes and Data Lists
- Deep Learning 读书笔记(十三):Improving Word Representations via Global Context and Multiple Word Prototype
- 数据库中间件OneProxy and onemysql