Installing Mod-Proxy-Html and Proxying Virtuoso Via Apache2
来源:互联网 发布:人工神经网络 知乎 编辑:程序博客网 时间:2024/04/30 15:36
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 References
Introduction
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 proxysudo 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-htmlsudo a2enmod proxysudo a2enmod proxy_htmlsudo 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 networkssudo vim /etc/apache2/sites-enabled/000-default- Underput some forwarding parameters e.g.:ProxyPass /instance1 http://172.19.1.2sudo /etc/init.d/apache2 reloadNavigate 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 proxyProxyRequests Off# Pass original host to VirtuosoProxyPreserveHost On# Timeout waiting for VirtuosoProxyTimeout 300# Set permissionOrder deny,allow Allow from all #ProxyHTMLLogVerbose On#LogLevel Info#LogLevel Debug# Configuring the links that will be re-writtenProxyHTMLLinks a hrefProxyHTMLLinks area hrefProxyHTMLLinks link hrefProxyHTMLLinks img src longdesc usemapProxyHTMLLinks object classid codebase data usemapProxyHTMLLinks q citeProxyHTMLLinks blockquote citeProxyHTMLLinks ins citeProxyHTMLLinks del citeProxyHTMLLinks form actionProxyHTMLLinks input src usemapProxyHTMLLinks head profileProxyHTMLLinks base hrefProxyHTMLLinks script src forProxyHTMLEvents onclick ondblclick onmousedown onmouseup / onmouseover onmousemove onmouseout onkeypress / onkeydown onkeyup onfocus onblur onload / onunload onsubmit onreset onselect onchange# Defining the URLs to proxyProxyPass 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
- Installing Mod-Proxy-Html and Proxying Virtuoso Via Apache2
- HTTP Proxy Servers and Proxying
- @Controller's and AOP Proxying
- Installing SVN Via MacPorts
- WebSocket via HTTP proxy
- Installing Apache2 With PHP5 And MySQL Support On Ubuntu 9.04 (LAMP)
- Apache2配置FastCGI(mod-fcgid)
- Git push via proxy + https
- Proxy and Reverse Proxy
- charles提示“SSL Proxying not enabled for this host: enable in Proxy Settings, SSL locations”
- Installing Git HTML help
- Installing Git HTML help
- Java Details: mod and %
- Installing and configuring Xen
- Installing and Testing ON
- Downloading and installing Hadoop
- Installing and Using Ftrace
- Installing freeglut and OpenGL
- Windows 7下的DEP解析
- 哈哈
- 玩玩新浪
- Infobright的架构
- shell 演讲稿
- Installing Mod-Proxy-Html and Proxying Virtuoso Via Apache2
- 心情2011谁能懂我现在的心情
- Java技巧:AJAX向Response留中输出Xml的办法
- 全面分析Java的垃圾回收机制
- java开发前奏
- AIX lsof安装
- VC++.net窍门
- 读C++Primer所得.1
- 高效分布式操作解决方案