User Tools

Site Tools


en:user_advanced:gs3_server

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:user_advanced:gs3_server [2016/11/16 23:53] – [Starting and Stopping Tomcat] kjdonen:user_advanced:gs3_server [2025/06/27 03:00] (current) – [Proxying Tomcat with Apache] kjdon
Line 1: Line 1:
-====== Advanced Server: Greenstone 3 ====== 
  
  
-===== Apache Tomcat =====+====== Greenstone 3 Apache Tomcat Server ====== 
 + 
 Tomcat is a servlet container, and Greenstone3 runs as a servlet inside it.  Tomcat is a servlet container, and Greenstone3 runs as a servlet inside it. 
 The file ''$GSDL3SRCHOME/packages/tomcat/conf/server.xml'' is the Tomcat configuration file.  The file ''$GSDL3SRCHOME/packages/tomcat/conf/server.xml'' is the Tomcat configuration file. 
Line 17: Line 18:
 localhost:8383/greenstone3/sites/localsite/collect/gs2mgdemo/images/. localhost:8383/greenstone3/sites/localsite/collect/gs2mgdemo/images/.
  
-==== Starting and Stopping Tomcat ====+===== Starting and Stopping Tomcat =====
  
 Greenstone provides a little server program which will start the Tomcat server and open the library in a browser. See the [[en:user:greenstone_server|Greenstone Server]] page in the User's Guide. Greenstone provides a little server program which will start the Tomcat server and open the library in a browser. See the [[en:user:greenstone_server|Greenstone Server]] page in the User's Guide.
Line 23: Line 24:
  
 To start tomcat: To start tomcat:
-<code>$ ant start-tomcat</code>+<code>./ant-start-with-exts.sh (unix) or ant-start-with-exts.bat (windows)</code>
 OR: OR:
-<code>$ ant start</code>+<code> 
 +$ source ./gs3-setup.sh (unix) or gs3-setup.bat (windows) 
 +$ ant start</code> 
 To stop tomcat: To stop tomcat:
-<code>$ ant stop-tomcat</code>+<code>./ant-stop-with-exts.sh (unix) or ant-stop-with-exts.bat (windows)</code>
 OR: OR:
 <code>$ ant stop</code> <code>$ ant stop</code>
 To stop and then immediately start up again in one step, use restart: To stop and then immediately start up again in one step, use restart:
 +<code>$ ./ant-restart-with-exts.sh (unix) or ant-restart-with-exts.bat (windows)</code>
 +OR:
 <code>$ ant restart</code> <code>$ ant restart</code>
  
  
-==== Changing Tomcat Port Number ==== +===== Changing Tomcat Port Number ===== 
-Greenstone sets up Tomcat to run on port 8383 by default. To change this, you can edit the tomcat.port property in build.properties. If you do this before installing Greenstone, then running ’ant install’ will use the new port number. If you want to change it later on, shutdown tomcat, run ’ant configure’, then when you restart tomcat it will use the new port. +Greenstone sets up Tomcat to run on port 8383 by default. To change this, you can edit the tomcat.port property in build.properties. You will need to restart Tomcat for this to take effect (ant-restart-with-exts.sh/bat).
-Alternatively, you can change the port number in the File->Settings... menu of the Grennstone Server program, run with gs3-server.sh.+
  
-==== Changing Tomcat settings ==== +Alternatively, you can change the port number in the File->Settings... menu of the Greenstone Server program, run with gs3-server.sh/bat
-Don't edit the configuration files in Tomcat directly. Edit the versions in $GSDL3SRCHOME/resources/tomcat: greenstone3.xml (copied to $GSDL3SRCHOME/packages/tomcat/conf/Catalina/localhost/greenstone3.xml); server_tomcat7.xml (copied to $GSDL3SRCHOME/packages/tomcat/conf/server.xml); +
-web.xml (copied to $GSDL3SRCHOME/packages/tomcat/confi/web.xml).+
  
-'ant configure-tomcat' will copy these files to their correct places, replacing variable placeholders with their correct values. This is done each time Tomcat is restarted via Ant. Therefore any changes to the files in the Tomcat folder will be overwritten each time Tomcat is restarted.+===== Changing Tomcat settings ===== 
 +Don't edit the configuration files in Tomcat directly. Edit the versions in $GSDL3SRCHOME/resources/tomcat:  
 +  * greenstone3.xml.in (copied to $GSDL3SRCHOME/packages/tomcat/conf/Catalina/localhost/greenstone3.xml) 
 +  * server_tomcat8.xml.in (copied to $GSDL3SRCHOME/packages/tomcat/conf/server.xml) 
 +  * web8.xml.in (copied to $GSDL3SRCHOME/packages/tomcat/conf/web.xml) 
 +  * root_context.xml.in (copied to $GSDL3SRCHOME/packages/tomcat/conf/context.xml) 
 + 
 +'ant configure' will copy these files to their correct places, replacing variable placeholders with their correct values. This is done each time Tomcat is restarted. Therefore any changes to the files in the Tomcat folder will be overwritten each time Tomcat is restarted.
  
 Note: Tomcat must be shutdown and restarted any time you make changes in the following Note: Tomcat must be shutdown and restarted any time you make changes in the following
Line 48: Line 58:
  
   * ''$GSDL3HOME/WEB-INF/web.xml ''   * ''$GSDL3HOME/WEB-INF/web.xml ''
-  * ''$GSDL3SRCHOME/resources/tomcat/*.xml''  +  * ''$GSDL3HOME/WEB-INF/servlets.xml '' 
 +  * ''$GSDL3SRCHOME/resources/tomcat/*.xml.in''  
   * any classes or jar files used by the servlets  (if reloadable is set to false, see [[#xxx|below]].   * any classes or jar files used by the servlets  (if reloadable is set to false, see [[#xxx|below]].
  
 We have disabled following symlinks for the greenstone servlet.  We have disabled following symlinks for the greenstone servlet. 
-To enable it, edit $GSDL3SRCHOME/resources/tomcat/greenstone3.xml and  +To enable it, edit $GSDL3SRCHOME/build.properties and  
-set ’allowLinking’ to true. Restart Tomcat.+set ’tomcat.user.allowLinking’ to true. Restart Tomcat.
  
-By default, Tomcat allows directory listings. To disable this, change the ’listings’ +Tomcat can be configured to allow or disallow directory listings. To check or change the settings, look for the ’listings’ 
- parameter to false in the default servlet definition, in Tomcat’s web.xml file  + parameter in the default servlet definition, in $GSDL3SRCHOME/resources/tomcat/web8.xml.in. Set it to false to disable directory listings. Restart Tomcat.
-($GSDL3SRCHOME/resources/tomcat/web.xml). Restart Tomcat.+
  
 We have set the greenstone context to be reloadable.  We have set the greenstone context to be reloadable. 
 This means that if a class or resource file in $GSDL3HOME/WEB-INF/lib or $GSDL3HOME/WEB-INF/classes changes, This means that if a class or resource file in $GSDL3HOME/WEB-INF/lib or $GSDL3HOME/WEB-INF/classes changes,
  the servlet will be reloaded. This is useful for development, but should be turned off for   the servlet will be reloaded. This is useful for development, but should be turned off for 
-production mode: set the ’reloadable’ attribute to false in $GSDL3SRCHOME/resources/tomcat/greenstone3.xml. Restart Tomcat.+production mode: set the ’reloadable’ attribute to false in $GSDL3SRCHOME/resources/tomcat/greenstone3.xml.in. Restart Tomcat.
  
-==== Changing collections or services ====+If you are seeing lots of errors in packages/tomcat/logs/catalina.out like the following, then consider increasing the maximum size of the cache - edit the cacheMaxSize attribute on the Resources element in resources.tomcat/greenstone3.xml.in. 
 +<code>org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [... class name ...]  
 +to the cache for web application [/greenstone3] because there was  
 +insufficient free space available after evicting expired cache entries</code> 
 + 
 +==== Using Greenstone inside a frame ==== 
 + 
 +Greenstone's cookies are SameSite=none by default (prior to April 2024) or after that, SameSite=strict. Browsers nowadays handle samesite=none in different ways. To get Greenstone to work properly inside a frame, the cookies need to be SameSite=none, partitioned=true. This needs a later version of Tomcat. 
 +From April 2024, we use a newer version of Tomcat (8.5.99) instead of 8.5.51. This has the ability to set partitioned for cookies.  
 +This feature is available in Greenstone 3.12 and later. 
 +Edit resources/tomcat/greenstone3.xml.in - comment out the CookieProcessor line setting strict, and uncomment the one setting none + partitioned. Then restart Tomcat 
 +<code> 
 +<!-- if greenstone is to be run in an iframe, need to use the --> 
 +<!-- sameSiteCookies=none version of the CookieProcessor --> 
 +  <CookieProcessor sameSiteCookies="none" partitioned="true"/> 
 +  <!--<CookieProcessor sameSiteCookies="strict"/>--> 
 +</code> 
 + 
 +==== Turn off localhost access logs ==== 
 + 
 +By default, one of the enabled forms of logging in Apache Tomcat is the Local Host Access Log.  This log tracks every connection made to the server. This can add up to a lot of logs that can quickly overwhelm the hard drive space of your server.  
 + 
 +To disable this, edit resources/tomcat/server_tomcat8.xml.in 
 + 
 +Look for the ''<Valve className="org.apache.catalina.valves.AccessLogValve".../>'' section and comment it out by surrounding it in ''<nowiki><!--  --></nowiki>'' 
 + 
 +===== Changing collections or services =====
 On startup, the servlet loads in its site, collections and services. On startup, the servlet loads in its site, collections and services.
 If the site or collection configuration files are changed, these changes will not take  If the site or collection configuration files are changed, these changes will not take 
Line 70: Line 106:
  messages (see Section ?), or by restarting Tomcat.  messages (see Section ?), or by restarting Tomcat.
  
-==== Tomcat Session Handling ====+===== Tomcat Session Handling =====
  
 Tomcat uses a Manager to handle HTTP session information. The Manager is specified in a <Manager> element in the greenstone3.xml context file. By default, Greenstone uses the standard Tomcat default manager. Tomcat uses a Manager to handle HTTP session information. The Manager is specified in a <Manager> element in the greenstone3.xml context file. By default, Greenstone uses the standard Tomcat default manager.
  
-Session information is stored between normal stop and starts in $GSDL3SRCHOME/packages/tomcat/work/Catalina/localhost/greenstone3/SESSIONS.ser. To disable storing session info between restarts, set the pathname attribute of the Manager element to "" in $GSDL3SRCHOME/resources/tomcat/greenstone3.xml.+Session information is stored between normal stop and starts in $GSDL3SRCHOME/packages/tomcat/work/Catalina/localhost/greenstone3/SESSIONS.ser. To disable storing session info between restarts, set the pathname attribute of the Manager element to "" in $GSDL3SRCHOME/resources/tomcat/greenstone3.xml.in.
  
 To manually clear saved session info, stop Tomcat and delete the SESSIONS.ser file. To manually clear saved session info, stop Tomcat and delete the SESSIONS.ser file.
Line 80: Line 116:
  
  
-==== Proxying Tomcat with Apache ====+===== Proxying Tomcat with Apache =====
 Instead of incorporating servlet support into your existing web server,  Instead of incorporating servlet support into your existing web server, 
 an easy alternative is to proxy Tomcat. The http://www.greenstone.org/greenstone3 site  an easy alternative is to proxy Tomcat. The http://www.greenstone.org/greenstone3 site 
Line 90: Line 126:
 ServerName www.greenstone.org ServerName www.greenstone.org
 ... ...
-ProxyPass /greenstone3 http://puka.cs.waikato.ac.nz:8080/greenstone3 + 
-ProxyPassReverse /greenstone3 http://puka.cs.waikato.ac.nz:8080/greenstone3+Redirect /greenstone3 /greenstone3/ 
 +ProxyPass /webswing-server/ http://puka.cs.waikato.ac.nz:8383/webswing-server/ upgrade=websocket 
 +ProxyPass /greenstone3http://puka.cs.waikato.ac.nz:8080/greenstone3 
 +ProxyPassReverse /greenstone3http://puka.cs.waikato.ac.nz:8080/greenstone3 
 +<Location /greenstone3> 
 +          ProxyPassReverseCookiePath /greenstone3 /greenstone3 
 +</Location>
 </VirtualHost> </VirtualHost>
 </code> </code>
 +
 +Restart Apache for these changes to take effect.
  
 In our example, the Greenstone3 servlet can be accessed at  In our example, the Greenstone3 servlet can be accessed at 
Line 99: Line 143:
 http://puka.cs.waikato.ac.nz:8080/greenstone3/library, which is not publicly accessible. http://puka.cs.waikato.ac.nz:8080/greenstone3/library, which is not publicly accessible.
  
 +You will also need to tell Greenstone itself about the new web address. Edit **build.properties**.
 +Set the revproxy fields:
 +<code>
 +revproxy.protocol=https
 +revproxy.domain=www.greenstone.org
 +##revproxy.opt_port=8383
 +##revproxy.context=greenstone3
 +</code>
 +
 +You will also need to edit **resources/web/servlets.xml.in**
 +Uncomment and set the servlet_url_prefix param:
 +<code>
 +<init-param>
 +   <param-name>servlet_url_prefix</param-name>
 +   <param-value>//www.greenstone.org/greenstone3/</param-value>
 +</init-param>
 +</code>
 +
 +You will need to restart Tomcat for these settings to take effect.
 === Running Tomcat behind a proxy === === Running Tomcat behind a proxy ===
 Almost everything works fine when Tomcat is running behind a proxy.  Almost everything works fine when Tomcat is running behind a proxy. 
Line 112: Line 175:
  
  
-==== Deploying a Soap Server on localsite ====+===== Deploying a Soap Server on localsite =====
  
  
Line 120: Line 183:
 <code>$ ant stop</code> <code>$ ant stop</code>
 Then, deploy  Then, deploy 
-(as written in the [[http://www.greenstone.org/docs/greenstone3/manual.pdf|Greenstone 3 manual]], p. 5):+(as written in the [[http://files.greenstone.org/technical/gs3manual.pdf|Greenstone 3 manual]], p. 5):
 <code>$ ant deploy-localsite</code> <code>$ ant deploy-localsite</code>
 Check that it works, by **starting** tomcat again and going to: Check that it works, by **starting** tomcat again and going to:
Line 126: Line 189:
 Make sure that the page appears. You can also look at the wsdl file for the gs3 web service that's been exposed:  Make sure that the page appears. You can also look at the wsdl file for the gs3 web service that's been exposed: 
 <code>http://localhost:8080/greenstone3/services/localsite?wsdl</code> <code>http://localhost:8080/greenstone3/services/localsite?wsdl</code>
-You can also deploy other sites, see the [[http://www.greenstone.org/docs/greenstone3/manual.pdf|Greenstone 3 Developer's Manual]]. +You can also deploy other sites, see the [[http://files.greenstone.org/technical/gs3manual.pdf|Greenstone 3 Developer's Manual]].
  
en/user_advanced/gs3_server.1479340394.txt.gz · Last modified: 2016/11/16 23:53 by kjdon