Management System / Public Website / Signup / Account Manager

From JCWiki
Jump to navigation Jump to search

Overview

These systems are all running under the same apache instance on the mail server.

The main ingredients are: apache 1.3.31, mysql, perl, mod_perl and template toolkit.

Apache is listening on 69.55.230.9 ports 80 and 443

The webserver can be stopped with:

apachectl stop

and must be started with:

apachectl startssl

If you run apachectl start none of the ssl-enabled pages will work.

The database may be stopped and started as follows:

/usr/local/etc/rc.d/mysql-server.sh stop
/usr/local/etc/rc.d/mysql-server.sh start
  • webroot: /usr/local/www/
  • logs: /var/log/httpd-error.log /var/log/httpd-access.log
  • Apache config:
/usr/local/etc/apache/httpd.conf:
-SNIP-
<Directory /usr/local/www>
 Options none
</Directory>


<VirtualHost *>
  SSLDisable
  DocumentRoot /usr/local/www/jc_pub
  ServerName johncompanies.com
  ServerAlias www.johncompanies.com
  ServerAlias newwww.johncompanies.com

  <Directory /usr/local/www/jc_pub>
    Options FollowSymLinks
  </Directory>

  Redirect /collocation http://www.johncompanies.com
  Redirect /colocation http://www.johncompanies.com

  ScriptAlias /cgi-bin/ "/usr/local/www/jc_pub/cgi-bin/"
  <Directory /usr/local/www/jc_pub/cgi-bin>
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
    SetHandler None
  </Directory>

</VirtualHost>

<VirtualHost *>
  ServerName mini.johncompanies.com
  SSLDisable
  DocumentRoot /usr/local/www/mini

  <Directory /usr/local/www/mini>
    Options FollowSymLinks
  </Directory>

</VirtualHost>


<VirtualHost _default_:443>

  DocumentRoot "/usr/local/www"

  DocumentRoot /usr/local/www
  <Directory /usr/local/www>
    Deny from All
  </Directory>
  <Directory /usr/local/www/mgmt>
    Allow from All
  </Directory>
  <Directory /usr/local/www/am>
    Allow from All
  </Directory>
  <Directory /usr/local/www/signup>
    Allow from All
  </Directory>
  <Directory /usr/local/www/images>
    Allow from All
  </Directory>
  <Directory /usr/local/www/media>
    Allow from All
  </Directory>
  <Files favicon.ico>
    Allow from All
  </Files>

  SSLEngine on
  SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

#  SSLCertificateFile         /usr/local/etc/apache/mail.cert
#  SSLCertificateKeyFile     /usr/local/etc/apache/mail.key
  #SSLCertificateFile         /usr/local/etc/apache/ssl.crt/secure.crt
  SSLCertificateFile         /usr/local/etc/apache/ssl.crt/secure.johncompanies.com.crt
  SSLCertificateChainFile    /usr/local/etc/apache/ssl.crt/gd_bundle.crt
  SSLCertificateKeyFile     /usr/local/etc/apache/ssl.key/secure.key

  PerlModule Apache

  # debug stuff
  PerlWarn On
  PerlTaintCheck Off
  PerlModule Apache::StatINC
  PerlInitHandler Apache::Reload
# CustomLog /usr/local/apache/logs/access_log.mgmt common
# ErrorLog /usr/local/apache/logs/error_log.mgmt

  PerlModule Apache::DBI
#  PerlModule Mgmt
#  PerlModule Auth

  PerlSetEnv MGMT_BASE /usr/local/www/mgmt
  PerlSetEnv COMMON_BASE  /usr/local/www/common
  PerlSetEnv SIGNUP_BASE  /usr/local/www/signup
  PerlSetEnv AM_BASE /usr/local/www/am
  PerlSetEnv MGMT_INDEX /mgmt/index.html
  PerlSetEnv SIGNUP_INDEX /signup/step1.html
  PerlSetEnv AM_INDEX /am/dashboard.html
  PerlSetEnv MGMT_LOG_LEVEL debug
  PerlSetEnv MGMT_LOG_FILE /usr/local/www/mgmt/Log/mgmt.log
  PerlSetEnv SIGNUP_LOG_LEVEL info
  PerlSetEnv SIGNUP_LOG_FILE /usr/local/www/signup/Log/signup.log
  PerlSetEnv AM_LOG_LEVEL debug
  PerlSetEnv AM_LOG_FILE /usr/local/www/am/Log/am.log
  PerlSetEnv PP_AUTH_TOKEN Pe3aLk5GdMblAyyLAv5vNYqipcynWdZJKdw1CmcGcIdOz74ujMrDYIov27i
  PerlSetEnv PP_URL 'https://www.paypal.com/cgi-bin/webscr'
  PerlSetEnv PP_EMAIL 'payments@johncompanies.com'
  PerlSetEnv JC_DOMAIN 'secure.johncompanies.com'
  PerlSetEnv CC_LOG_FILE /usr/local/www/mgmt/Log/cc.log
  PerlSetEnv DEV 0
  PerlRequire /usr/local/www/common/conf/startup.pl

  <Directory "/usr/local/www/mgmt">
    SetHandler perl-script
    PerlHandler Mgmt
    PerlSetVar JCMGMTPath /mgmt
    PerlSetVar JCMGMTLoginScript /mgmt/login.html

    <Files LOGIN>
      AuthType Auth
      AuthName JCMGMT
      SetHandler perl-script
      PerlHandler Auth->login
    </Files>

    <FilesMatch ".*\.html$|.*\.cgi|.*\.png">
      AuthType Auth
      AuthName JCMGMT
      PerlAuthenHandler Auth->authenticate
      PerlAuthzHandler  Auth->authorize
      require valid-user
    </FilesMatch>
  </Directory>

  <Directory "/usr/local/www/am">
    SetHandler perl-script
    PerlHandler AM
    PerlSetVar JCAMPath /am
    PerlSetVar JCAMLoginScript /am/login.html
    #PerlSetVar JCAMExpires +1m

    <Files LOGINAM>
     AuthType AMAuth
     AuthName JCAM
     SetHandler perl-script
     PerlHandler AMAuth->login
    </Files>

    <Files PASSRESET>
     SetHandler perl-script
     PerlHandler AMPassR
    </Files>

    <FilesMatch ".*\.html$|.*\.cgi">
     AuthType AMAuth
     AuthName JCAM
     PerlAuthenHandler AMAuth->authenticate
     PerlAuthzHandler AMAuth->authorize
     require valid-user
    </FilesMatch>
  </Directory>

  <Directory /usr/local/www/mgmt/static>
    SetHandler None
  </Directory>

  <Directory /usr/local/www/am/static>
    SetHandler None
  </Directory>

  <Directory /usr/local/www/mgmt/bwgraphs>
    SetHandler None
  </Directory>

  <Directory /usr/local/www/am/bwgraphs>
    SetHandler None
  </Directory>

  <Directory /usr/local/www/images>
    SetHandler None
  </Directory>

  <Directory /usr/local/www/media>
    SetHandler None
  </Directory>
  <Directory /usr/local/www>
    Options FollowSymlinks
  </Directory>

  ScriptAlias /mgmt/cgi/ "/usr/local/www/mgmt/cgi/"

  <Directory /usr/local/www/mgmt/cgi>
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
    SetHandler None
    AuthType Auth
    AuthName JCMGMT
    PerlAuthenHandler Auth->authenticate
    PerlAuthzHandler  Auth->authorize
    require valid-user
  </Directory>

  <Directory "/usr/local/www/signup">
    SetHandler perl-script
    PerlHandler Signup
  </Directory>

  Alias /mgmt/mrtg "/usr/local/www/mgmt/mrtg/data"
  <Directory /usr/local/www/mgmt/mrtg/data/>
    DirectoryIndex index.cgi
    SetHandler None
    Options ExecCGI
    AddHandler cgi-script .cgi
  </Directory>

  Alias /mgmt/rrd "/usr/local/www/mgmt/mrtg/rrd"
  <Directory /usr/local/www/mgmt/mrtg/rrd/>
    DirectoryIndex index.html
    SetHandler None
  </Directory>

  ScriptAlias /mgmt/bb/cgi-bin/ /usr/home/bb/bbsrc/bb1.9i-btf/web/
  Alias /mgmt/bb "/usr/home/bb/bbsrc/bb1.9i-btf/www"
  <Directory /usr/home/bb/bbsrc/bb1.9i-btf/www/gifs>
    SetHandler None
  </Directory>
  <Directory /usr/home/bb/bbsrc/bb1.9i-btf/web>
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
    PerlSetVar JCMGMTLoginScript /mgmt/login.html
    AuthType Auth
    AuthName JCMGMT
    PerlAuthenHandler Auth->authenticate
    PerlAuthzHandler  Auth->authorize
    require valid-user
  </Directory>
  <Directory /usr/home/bb/bbsrc/bb1.9i-btf/www>
    PerlSetVar JCMGMTLoginScript /mgmt/login.html
    AuthType Auth
    AuthName JCMGMT
    PerlAuthenHandler Auth->authenticate
    PerlAuthzHandler  Auth->authorize
    require valid-user
  </Directory>

  Alias /mgmt/awstatsclasses "/usr/local/www/mgmt/awstats/wwwroot/classes/"
  Alias /mgmt/awstatscss "/usr/local/www/mgmt/awstats/wwwroot/css/"
  Alias /mgmt/awstatsicons "/usr/local/www/mgmt/awstats/wwwroot/icon/"
  ScriptAlias /mgmt/awstats/ "/usr/local/www/mgmt/awstats/wwwroot/cgi-bin/"
  Alias /mgmt/icon/ "/usr/local/www/mgmt/awstats/wwwroot/icon/"

  <Directory "/usr/local/www/mgmt/awstats/wwwroot/icon">
    SetHandler None
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>


  <Directory "/usr/local/www/mgmt/awstats/wwwroot">
    PerlSetVar JCMGMTLoginScript /mgmt/login.html
    AuthType Auth
    AuthName JCMGMT
    PerlAuthenHandler Auth->authenticate
    PerlAuthzHandler  Auth->authorize
    require valid-user
    SetHandler None
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

Template Toolkit

http://www.template-toolkit.org/docs/manual/index.html

All our dynamic content pages (i.e. anything but jcpub) makes use of the Template Toolkit (TT) framework to create/display our pages. This package allows us to create customied apache handlers via the use of mod_perl. The result is an easy to deploy, easy to develop, flexible and efficient platform.

All these sites are organized under /usr/local/www and consist/rely on several components:

  • common/conf/startup.pl - this contains all the use/require code that brings in all the required libraries and modules required to run our sites and TT. It is run once as apache starts up and applies to all sites.
  • common/conf/Lib - this directory contains all common libraries, primarly those dealing with database access and access to individual tables.

Part of TT's efficiency comes from static and natively compiled code/pages. However, we have also enabled apache modules/directives which direct apache to rebuild these pages when it notices there's a difference:

. When running, apache and TT will work together to create automatically

  • common - all these sites share a common

Public Website (jcpub)

Our public-facing website is all static, standard HTML. We have some light javascripting on some pages, but by in large it's a very WYSIWYG site setup.

Signup (signup)


Management System (mgmt)


mrtg

All configuration is done via *.cfg files. The main load graph is found in mrtg1.cfg All other config files are for various switches. Switch config files are rebuilt out of a cron jobs running on mail. This ensures if we change a port name (desc) that the mrtg we look at has the latest info. So if you want to change port naming, please do it in the switch itself. If you have problems getting new devices setup or change existing devices you may need to change permissions on the cfg file as well as the data file in /usr/local/www/mgmt/mrtg/data, including removal of the rrd file if necessary.


Errors

"Lock wait timeout exceeded"

delete error - Can't delete a2206e24: DBD::mysql::st execute failed: Lock wait timeout exceeded; try restarting transaction [for Statement "DELETE FROM invoice WHERE inv_ref=? "] at /usr/local/lib/perl5/site_perl/5.6.1/DBIx/ContextualFetch.pm line 51. at /usr/local/www/mgmt/Plugin/Billing.pm line 1934

This is the result of an unclean submit/commit. Usually from an error or a double click on something that should have been single click. To clear this up, restart the database:

mail /usr/local/www/scripts# /usr/local/etc/rc.d/mysql-server.sh stop
mysqldmail /usr/local/www/scripts#

It takes a minute to shutdown. I keep running the command until it says it isn't running, then I start it:

mail /usr/local/www/scripts# /usr/local/etc/rc.d/mysql-server.sh stop
 mysqldmail /usr/local/www/scripts# /usr/local/etc/rc.d/mysql-server.sh stop
 mysqldmail /usr/local/www/scripts# /usr/local/etc/rc.d/mysql-server.sh stop
mysql-server isn't running
mail /usr/local/www/scripts# /usr/local/etc/rc.d/mysql-server.sh start
 mysqldmail /usr/local/www/scripts#


Account Manager (AM)


Problems

Power management: Status and control temporarily unavailable

ATS isn't responding. See ATS#Rebooting_and_Recovering