Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Install nginx (this is OS and distribution-specific step) - Details on how to install Nginx can be found at http://wiki.nginx.org/Install

  2. Make sure that Tomcat accepts HTTP requests from localhost (by default on 8080 port)

  3. In order to web application resolve client IP address, protocol, you need to add the following:

    Code Block
    languagehtml/xml
     <Valve className="org.apache.catalina.valves.RemoteIpValve" protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https" /> in server.xml (remove 'protocolHeaderHttpsValue' attribute in case of non-SSL setup)
  4. Configure /etc/nginx/conf.d/default.conf (default directory of included config files for CentOS nginx installation): 

       
Code Block
Server {
    listen   80;
    server_name portal.example.com www.portal.example.com;
    charset utf-8;
 
    location / { 
      proxy_pass  http://localhost:8080;
 
      # Next headers are required in order to allow tomcat to resolve client address (not proxy)
      # In ${tomcat}/conf/server.xml add this line:
      # <Valve className="org.apache.catalina.valves.RemoteIpValve protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https" />
    
      proxy_set_header  X-Real-IP  $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        Host $http_host;
      proxy_buffer_size       8k;
      proxy_buffers           16 32k;  
      proxy_busy_buffers_size 64k;
    }
    location ~ /(WEB-INF|META-INF) {
       deny  all;
    }
}

 

...

Code Block
languagebash
#! /bin/bash


# Schedule this script using contab expression:
#   55 0 * * * /home/tomcat/create_gz_files.sh >> /dev/null 2>&1

FILETYPES="*.css *.jpg *.jpeg *.gif *.png *.js *.html"

# specify a list of directories to check recursively
DIRECTORIES="/directory/to/compress/*/another/directory/to/compress/*"

for currentdir in $DIRECTORIES

do
  for extension in $FILETYPES
   do
     #echo $currentdir
     find $currentdir -iname $extension -exec bash -c 'PLAINFILE={};GZIPPEDFILE={}.gz; 

     if [ -e $GZIPPEDFILE ]; 
     	then if [ `stat --printf=%Y $PLAINFILE` -gt `stat --printf=%Y $GZIPPEDFILE`]; 
                  then    echo "$GZIPPEDFILE outdated, regenerating"; 
                  gzip -9 -f -c $PLAINFILE > $GZIPPEDFILE; 
                  touch -r $PLAINFILE $GZIPPEDFILE ; 
             fi; 
        else echo "$GZIPPEDFILE is missing, creating it"; 
        gzip -9 -c $PLAINFILE > $GZIPPEDFILE; 
        touch -r $PLAINFILE $GZIPPEDFILE ; 
     fi';
   done
done

 

 

Warning
iconfalse
titleHaving problems with these instructions?

Please send us feedback at uportal-user@lists.ja-sig.org