
NameVirtualHost *

################### BEGIN SGN ###################
<VirtualHost *>
    #set an environmental variable which will allow modules which are used by multiple virtual hosts (for instance, CXGN::Page) to find out which virtual host they are running on
    PerlSetEnv PROJECT_NAME SGN
    #set an environmental variable for cookies as implemented by CXGN::Page (i suspect this would not be necessary if we were doing cookies correctly --john)
    PerlSetEnv SERVERNAME sgn-devel.localhost.localdomain
    #set an environmental variable for basepath, since there may be more than one basepath for similar configurations, if multiple users have similar vhost setups on a machine
    PerlSetEnv BASEPATH /data/local/cxgn/sgn
    #are we running as a production server
    PerlSetEnv PRODUCTION_SERVER 0
    #tell perl where to look for modules
    PerlSetEnv PERL5LIB /usr/local/lib/site_perl
    #the name of the virtual host we are defining
    ServerName sgn-devel.localhost.localdomain
    #and any aliases


    #supposedly reloads all scripts and modules after a restart but does not seem to work. you must actually stop and start apache as two steps. --john
    PerlFreshRestart On
    #give warnings
    PerlWarn On
    #do not allow raw user-submitted data to be eval'd or used in system calls
    PerlTaintCheck Off 

    #who to email with problems
    ServerAdmin sgn-feedback@sgn.cornell.edu

    #respond to all requests by looking in this directory...
    DocumentRoot /data/local/cxgn/sgn/cgi-bin

    #where to write error messages
    ErrorLog /data/local/cxgn/sgn/logs/sgn-error.log
    CustomLog /data/local/cxgn/sgn/logs/sgn-access.log combined
    CustomLog /data/local/cxgn/sgn/logs/sgn-access.log timing

    <Directory />
        #allow symlinks
        Options +FollowSymLinks
        #specify who can come to our website
#        AuthName "Development site; contact sgn-feedback@sgn.cornell.edu if you need access"
#        AuthType Basic
#        AuthUserFile /etc/cxgn/htpasswd-SGN
#        Require valid-user
#        Order deny,allow
#        Deny from all
#        Allow from 127.0.0.0/26
#        Allow from 132.236.157.64/26
#        Allow from 128.253.40.0/26
#        Satisfy Any

    </Directory>

    #when a page is forbidden, go here    
    #ErrorDocument 403 /tools/http_error_handler.pl

    #when a page is not found, go here    
    ErrorDocument 404 /tools/http_error_handler.pl

    #when a script dies, go here. this should always be handled by CXGN::Apache::Registry, but sometimes things break badly. LEAVE THE INITIAL QUOTE IN (unless replacing this with a path to a file)
    ErrorDocument 500 "Internal server error: The server encountered an internal error or misconfiguration and was unable to complete your request. Feel free to contact us at sgn-feedback@sgn.cornell.edu and inform us of the error.

    Alias /data /data/prod/public
    <Directory /data/prod/public>
        AllowOverride All
        Options +Indexes -ExecCGI +FollowSymLinks
        Order allow,deny
        Allow from all
    </Directory>

    <Directory /data/local/cxgn/sgn/cgi-bin>
        AllowOverride All
        #execute cgi scripts, auto indexing of directories
	Options +ExecCGI +Indexes
        #if only a directory is specified, look for index.pl.
        DirectoryIndex index.pl
        #reuse database connections rather than getting new ones every time a new query is made
        PerlModule Apache::DBI 
        #autoreloading of modules
        PerlModule Apache::StatINC
        PerlInitHandler Apache::StatINC

        #set up perl script parsing
	SetHandler perl-script
        #use this module
        PerlModule CXGN::Apache::Registry
        #send perl scripts to this module for parsing
	PerlHandler CXGN::Apache::Registry
        #send things that look like http headers as http headers
        PerlSendHeader On
        #the output of our perl scripts is to be interpreted as text/html
	AddType text/html .pl
        #the favicon is expected to be right under document root, but don't execute 
        <Files favicon.ico>
            SetHandler none
        </Files>
        #the robots.txt file is expected to be right under document root, but don't execute 
        <Files robots.txt>
            SetHandler none
        </Files>
    </Directory>

    <Directory /data/local/cxgn/sgn/documents/tempfiles>
        DefaultType text/plain
    </Directory>

    #SGN VHOST SUBCLASS CONFIGURATION

    #documents folder requests go here (not to be confused with apache's document root... sorry if confusing. --john)
    Alias /documents /data/local/cxgn/sgn/documents
    #cgi-bin requests go here
    Alias /cgi-bin /data/local/cxgn/sgn/cgi-bin
    #insitu image locations
    Alias /fullsize_images "/data/prod/public/images/insitu/processed"
    Alias /thumbnail_images "/data/prod/public/images/insitu/display"
    # Alias for static files that reside in /data/shared/website
    Alias /static "/data/prod/public"
	
    Alias /js "/data/local/cxgn/jslib"

    <Files *.cgi>
       SetHandler cgi-script
    </Files>


    RewriteEngine On
    RewriteLogLevel 1
    RewriteLog /data/local/cxgn/sgn/logs/sgn-rewrite.log


	</VirtualHost>
################### END SGN #####################
