|
|
|
FAQ Download Client Install Server Install Help Docs Neolectric |
|
DataView Server SetupThe DataView Client can connect to the demo server listed in the client download. If you want to connect to your own server there are 4 components required.
The Tomcat servlet runner can act as a standalone webserver but I prefer to use Apache as the webserver and use an Apache module to connect to Tomcat. This allows Apache to do what it's really good at: deliver static files; encode/decode ssl; run other web frameworks like php; listen on port 80 (the standard http port) while running as a non-privileged user with no login privilege. When you set up a Virtual Host directory structure you should think about who owns the files and what the file and directory permissions are should be. There are 3 user accounts and 1 group to consider:
These user accounts must exist on your system and are normally stored in /etc/password and /etc/group. Some systems use an ldap or nis server instead. Apache is started by user The user and group Apache runs under is specified in the file You may want to restrict the type of shell that the host account can login with. A common practice is to use /sbin/nologin which allows the user to upload via ftp but not get a shell. A better method is to create a chroot "jail" directory and use the rssh shell and restrict the webmaster to using sftp for uploads. Do a google search on rssh and filezilla (an sftp client) for details. Now we'll setup a directory that contains web files for |
#!/bin/bash # create a dir structure for a website that the host webmaster can update mkdir /home/host mkdir /home/host/htdocs mkdir /home/host/htdocs/error mkdir /home/host/htdocs/WEB-INF mkdir /home/host/prop mkdir /home/host/logs # restrict /home/host to host and webuser (group for apache and tomcat) chown host:webuser /home/host chmod o-wrx /home/host # restrict prop to tomcat chown tomcat:tomcat /home/host/prop chmod o-wrx /home/host/prop # give ownership of htdocs and error to host so the webmaster can update chown host:webuser /home/host/htdocs chown host:webuser /home/host/htdocs/error # restrict WEB-INF to tomcat chown tomcat:tomcat /home/host/htdocs/WEB-INF chmod o-wrx /home/host/htdocs/WEB-INF |
|
Next, we'll modify the main Apache config file |
file: /usr/local/apache/conf/httd.conf
(perhaps /etc/httpd/conf/httpd.conf if you installed from rpm)
# put in the IP address here
NameVirtualHost xxx.xxx.xxx.xxx.
<VirtualHost xxx.xxx.xxx.xxx>
ServerName hostname.com
ServerAlias www.hostname.com
ServerAdmin admin@hostname.com
DocumentRoot /home/host/htdocs
ErrorLog /home/host/log/error_log
ErrorDocument 401 /error/notauthorized.html
ErrorDocument 403 /error/forbidden.html
ErrorDocument 404 /error/notfound.html
ErrorDocument 500 /error/internalerr.html
ErrorDocument 503 /error/unavailable.html
CustomLog /home/host/log/access_log common
<Directory "/home/host/htdocs">
Options FollowSymLinks
AllowOverride AuthConfig
</Directory>
<Location /WEB-INF/ >
AllowOverride None
deny from all
</Location>
</VirtualHost>
|
|
When Apache starts up it loads various modules. You can tell Apache to pass requests for certain file types and file paths to Tomcat using the jk2 module. First you need to download and compile it. See the download page for location. Then you need to modify the main apache config file httpd.conf to load it. LoadModule jk2_module modules/mod_jk2.soThe jk2_module will look for the file workers2.properties in the same directory as httd.conf. Here is a sample that is set to pass requests for /dataview to Tomcat. |
file: /usr/local/apache/conf/workers2.properties
(perhaps /etc/httpd/conf/workers2.properties if you installed apache from rpm)
# A minimal JK2 connector configuration file to pass .dxp requests to Tomcat
[logger]
info=Native logger
level=ERROR
[config:]
file=${serverRoot}/conf/workers2.properties
debug=0
debugEnv=0
[uriMap:]
info=Maps the requests.
debug=0
[shm:]
info=Scoreboard. Required for reconfiguration and status with multiprocess servers
file=anonymous
debug=0
[workerEnv:]
info=Global server options
timing=0
debug=0
[lb:lb]
info=Default load balancer.
debug=0
[channel.socket:localhost:8009]
info=Ajp13 forwarding over socket
debug=0
tomcatId=localhost:8009
# pass requests for /dataview to Tomcat
[uri:/dataview]
info=dataview servlet
debug=0
# ucomment if you run .jsp pages
# [uri:/*.jsp]
# info=jsp servlet
# debug=0
|
|
This document was written for Tomcat version 5 which was downloaded as
cd /usr/local ln -s jakarta-tomcat-5.x tomcat These jar files contain classes required by the DataView servlet. mysql-connector-java-3.x.x-production-bin.jar xercesImpl.jar datview-version-server.jar See the download page to get them. Put them in
When Tomcat starts up it reads the file |
file: $TOMCAT_HOME/conf/server.xml
<Server port="8005" shutdown="SHUTDOWN">
<Service name="Catalina">
<!-- Define a Coyote/JK2 AJP 1.3 Connector (for apache) on port 8009 -->
<Connector port="8009" enableLookups="false"
redirectPort="8443" debug="0" protocol="AJP/1.3" />
<Engine name="Catalina" defaultHost="hostname.com" debug="4">
<Logger className="org.apache.catalina.logger.FileLogger" />
<!-- hostname.com host -->
<Host name="hostname.com" debug="4" appBase="/home/host/htdocs"
autoDeploy="false" xmlValidation="false" xmlNamespaceAware="true">
<Alias>www.hostname.com</Alias>
<Context path="" docBase="/home/host/htdocs" debug="0" reloadable="false"/>
</Host>
</Engine>
</Service>
</Server>
|
|
Based on the path you specified for appBase and docBase in server.xml above, Tomcat will
look for a a file called For safety we told Apache to stay out of this directory in httpd.conf. <Location /WEB-INF/ > AllowOverride None deny from all </Location> We also made this directory readable only by the tomcat user so a webmaster can't change it.
Here's a sample web.xml file for |
file: /home/host/htdocs/WEB-INF/web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Servlet config file ready by Tomcat for hostname.com.
Tomcat expects this file to be stored in the filepath docBase/WEB-INF/web.xml
where docBase is defined for each hostname in $TOMCAT_HOME/conf/server.xml.
Look in my server.xml file for each Host tag and it's nested Context tag
that defines the docBase. I normally use a docBase /home/hostname/htdocs
to match the DocumentRoot I set for the corresponding Apache VirtualHost. -->
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet> <!-- ContextServlet loads service classes into this host's ServletContext -->
<servlet-name>ctxtservlet</servlet-name>
<servlet-class>com.neolectric.servlet.ContextServlet</servlet-class>
<init-param> <!-- file that describes service classes -->
<param-name>contextFile</param-name>
<param-value>/home/host/prop/context.xml</param-value>
</init-param>
<init-param> <!-- xml parser that reads config values -->
<param-name>parser</param-name>
<param-value>org.apache.xerces.parsers.SAXParser</param-value>
</init-param>
<load-on-startup>1</load-on-startup> <!-- load this servlet first -->
</servlet>
<servlet> <!-- Servlet responds to DataView client -->
<servlet-name>dvservlet</servlet-name>
<servlet-class>com.neolectric.servlet.DvServlet</servlet-class>
<init-param>
<param-name>maxRead</param-name>
<param-value>1048576</param-value> <!-- 1MB tranlated to bytes -->
</init-param>
<init-param>
<param-name>docRoot</param-name>
<param-value>/home/host/htdocs/</param-value>
</init-param>
<init-param>
<param-name>userTable</param-name>
<param-value>dvusers</param-value>
</init-param>
<init-param>
<param-name>excludeDb</param-name> <!-- comma delim list of db pools to exclude -->
<param-value>secretdb,stuffdb</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>saxParser</param-name>
<param-value>org.apache.xerces.parsers.SAXParser</param-value>
</init-param>
</servlet>
<servlet-mapping> <!-- map urls passed by mod_jk2 -->
<servlet-name>dvservlet</servlet-name>
<url-pattern>/dataview</url-pattern>
</servlet-mapping>
<!-- docs (relative to host docroot) returned by servlet runner for various http errors -->
<error-page>
<error-code>401</error-code>
<location>/error/notauthorized.html</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/error/forbidden.html</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/error/notfound.html</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error/internalerr.html</location>
</error-page>
<error-page>
<error-code>503</error-code>
<location>/error/unavailable.html</location>
</error-page>
</web-app>
|
|
Note that the The ContexServlet is a custom servlet and has an <init-param> called
|
file: /home/host/prop/context.xml <?xml version='1.0' encoding='utf-8'?> <!-- This file is read by the ContextServlet to load service classes that are used in this Virtual Host. It contains sensitive information and should be stored outside the directory path that Apache or Tomcat serve pages from. --> <context name="hostname.com"> <!-- Load pools of database connections in this host zone. Do this before other services that depend on connections. You can load multiple pools but each must have a unique name. --> <DbService class="com.neolectric.dbutil.DbService"> <pool> <name>host</name> <!-- named used by DbService to store this connection pool --> <driver>org.gjt.mm.mysql.Driver</driver> <connections>4</connections> <!-- how many active connections to open --> <queue>4</queue> <!-- how many request can wait for a free connection --> <ping>select 1</ping> <!-- sql stmt used to see if a connection is live --> <user>bozo</user> <!-- user stored in database permission table --> <password>xxxxxxxx</password><!-- 8 char password --> <url>jdbc:mysql://host_or_ipaddr:3306/dbname</url> <!-- connection to database server --> </pool> </DbService> </context> |
|
The context file may contain other services. Only the DbService is shown in this example. |