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 [2025/06/27 01:20] – [Starting and Stopping Tomcat] kjdonen:user_advanced:gs3_server [2025/06/27 03:00] (current) – [Proxying Tomcat with Apache] kjdon
Line 41: Line 41:
  
 ===== 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.+ 
 +Alternatively, you can change the port number in the File->Settings... menu of the Greenstone Server program, run with gs3-server.sh/bat
  
 ===== Changing Tomcat settings ===== ===== Changing Tomcat settings =====
-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); +Don't edit the configuration files in Tomcat directly. Edit the versions in $GSDL3SRCHOME/resources/tomcat:  
-web.xml (copied to $GSDL3SRCHOME/packages/tomcat/confi/web.xml).+  * 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-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.+'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 54: 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. 
 + 
 +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 ===== ===== Changing collections or services =====
Line 80: Line 110:
 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 96: 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 105: 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  +You will also need to tell Greenstone itself about the new web address. Edit **build.properties**. 
-**web/sites/localsite/siteConfig.xml**. Add a line like the following to the <metadataList>:+Set the revproxy fields:
 <code> <code>
-<metadata name="siteURL">http://www.greenstone.org/greenstone3/</metadata>+revproxy.protocol=https 
 +revproxy.domain=www.greenstone.org 
 +##revproxy.opt_port=8383 
 +##revproxy.context=greenstone3
 </code> </code>
  
- +You will also need to edit **resources/web/servlets.xml.in** 
-Set up the tomcat.port and shutdown port in your ''build.properties'' file if different from the default 8383 and 8305 respectively. +Uncomment and set the servlet_url_prefix param:
- +
-Also edit these files ton contain the new url-prefix (if different from /greenstone3):+
 <code> <code>
- ./resources/web/global.properties.in +<init-param> 
- ./resources/web/global.properties+   <param-name>servlet_url_prefix</param-name> 
 +   <param-value>//www.greenstone.org/greenstone3/</param-value> 
 +</init-param>
 </code> </code>
-to change  
-<code>[email protected]@</code> 
-to 
-<code> 
- #[email protected]@ 
- tomcat.context=urban-narrative-greenstone3 
-</code> 
- 
-Don't forget to run (from GS3 folder): 
-<code> 
- ant configure-web 
-</code> 
-to regenerate the global.properties file in the actual web folder. 
- 
-Finally, to get everything running: 
-</code> 
-./gs3-setup.sh 
-ant start 
-<code> 
-Then 
-<code>ssh [email protected] (e.g. puka)</code> 
-In the same x-term, ssh -L back into the machine running the GS3 server: 
-<code>puka$ ssh -L port:localhost:port (you@)gs3-server.machine.domain</code> 
  
-On any browser, visit: +You will need to restart Tomcat for these settings to take effect.
-<code>remote.public.machine/url-prefix/library</code>+
 === 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. 
en/user_advanced/gs3_server.1750987207.txt.gz · Last modified: 2025/06/27 01:20 by kjdon