Class HttpdSiteManager
java.lang.Object
com.aoindustries.aoserv.daemon.httpd.HttpdSiteManager
- Direct Known Subclasses:
HttpdStaticSiteManager
,HttpdTomcatSiteManager
Manages Site configurations.
- Author:
- AO Industries, Inc.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
static class
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
By default, sites will block all TRACE and TRACK requests.protected abstract void
buildSiteDirectory
(PosixFile siteDirectory, String optSlash, Set<Site> sitesNeedingRestarted, Set<SharedTomcat> sharedTomcatsNeedingRestarted, Set<PosixFile> restorecon) (Re)builds the site directory, from scratch if it doesn't exist.void
configureFtpDirectory
(PosixFile ftpDirectory, Set<PosixFile> restorecon) Configures the anonymous FTP directory associated with this site.protected void
createCgiPhpScript
(PosixFile siteDirectory, PosixFile cgibinDirectory, Set<PosixFile> restorecon) Creates or updates the CGI php script, CGI must be enabled and PHP enabled.protected void
createTestIndex
(PosixFile indexFile) Creates the test index.html file if it is missing.boolean
Determines if should have anonymous FTP area.protected boolean
Determines if CGI should be enabled.protected boolean
Determines if PHP should be enabled.int
Gets the user ID that apache for this site runs as.Gets the auto-mode warning for this website for use in XML files.Gets the auto-mode warning for this website for use in XML files.static HttpdSiteManager
getInstance
(Site site) Gets the specific manager for one type of web site.Gets the JkMount and JkUnmounts for this site.Gets the set of permanent rewrite rules.Gets an unmodifiable map of URL patterns that should be rejected.protected Set
<PackageManager.PackageName> Gets any packages that must be installed for this site.abstract SortedMap
<String, HttpdSiteManager.WebAppSettings> Gets all the webapps for this site.static String
startHttpdSite
(int sitePkey) Starts the site if it is not running.static void
stopAndDisableDaemons
(PosixFile siteDirectory) Stops all daemons that may be running in the provided directory.static String
stopHttpdSite
(int sitePkey) Stops the site if it is running.
-
Field Details
-
httpdSite
-
-
Constructor Details
-
HttpdSiteManager
-
-
Method Details
-
getInstance
Gets the specific manager for one type of web site.- Throws:
IOException
SQLException
-
stopAndDisableDaemons
Stops all daemons that may be running in the provided directory. The exact type of site is not known. This is called during site clean-up to shutdown processes that should no longer be running. It is assumed that all types of sites will use the "daemon" directory with symbolic links that accept "start" and "stop" parameters.- Throws:
IOException
SQLException
- See Also:
-
startHttpdSite
Starts the site if it is not running. Restarts it if it is running.- Returns:
null
if successful or a user-readable reason if not successful- Throws:
IOException
SQLException
-
stopHttpdSite
Stops the site if it is running. Will return a message if already stopped.- Returns:
null
if successful or a user-readable reason if not success.- Throws:
IOException
SQLException
-
getAutoWarningXmlOld
Gets the auto-mode warning for this website for use in XML files. This may be used on any config files that a user would be tempted to change directly.- Throws:
IOException
SQLException
-
getAutoWarningXml
Gets the auto-mode warning for this website for use in XML files. This may be used on any config files that a user would be tempted to change directly.- Throws:
IOException
SQLException
-
getRequiredPackages
Gets any packages that must be installed for this site.By default, no specific packages are required.
- Throws:
IOException
SQLException
-
buildSiteDirectory
protected abstract void buildSiteDirectory(PosixFile siteDirectory, String optSlash, Set<Site> sitesNeedingRestarted, Set<SharedTomcat> sharedTomcatsNeedingRestarted, Set<PosixFile> restorecon) throws IOException, SQLException (Re)builds the site directory, from scratch if it doesn't exist. Creates, recreates, or removes resources as necessary. Also performs an automatic upgrade of resources if appropriate for the site. Also reconfigures any config files within the directory if appropriate for the site type and settings. If this site or other sites needs to be restarted due to changes in the files, add tositesNeedingRestarted
. If any shared Tomcat needs to be restarted due to changes in the files, add tosharedTomcatsNeedingRestarted
. Any files under siteDirectory that need to be updated to enable/disable this site should be changed. Actual process start/stop will be performed later instopStartAndRestart
.- If
siteDirectory
doesn't exist, create it as root with mode 0700 - If
siteDirectory
owned by root, do full pass (this implies manual=false regardless of setting) - Otherwise, make necessary config changes or upgrades while adhering to the manual flag
- Throws:
IOException
SQLException
- If
-
enableAnonymousFtp
public boolean enableAnonymousFtp()Determines if should have anonymous FTP area. -
configureFtpDirectory
public void configureFtpDirectory(PosixFile ftpDirectory, Set<PosixFile> restorecon) throws IOException, SQLException Configures the anonymous FTP directory associated with this site. If the site is disabled, will make owner root, group root, mode 0700. Will reset ownership and permissions as needed. This will only be called whenenableAnonymousFtp
returnstrue
. Manual mode has no impact on the ownership and permissions set.- Throws:
IOException
SQLException
- See Also:
-
enableCgi
protected boolean enableCgi()Determines if CGI should be enabled.- See Also:
-
enablePhp
Determines if PHP should be enabled.If this is enabled and CGI is disabled, then the HttpdServer for the site must use mod_php.
- Throws:
IOException
SQLException
- See Also:
-
createCgiPhpScript
protected void createCgiPhpScript(PosixFile siteDirectory, PosixFile cgibinDirectory, Set<PosixFile> restorecon) throws IOException, SQLException Creates or updates the CGI php script, CGI must be enabled and PHP enabled. If CGI is disabled or PHP is disabled, removes any php script. Any existing file will be overwritten, even when in manual mode.- Throws:
IOException
SQLException
-
createTestIndex
Creates the test index.html file if it is missing.TODO: Generate proper disabled page automatically. Or, better, put into logic of static site rebuild.
- Throws:
IOException
SQLException
-
getApacheUid
Gets the user ID that apache for this site runs as. If this site runs as multiple UIDs on multiple Apache instances, will return the "apache" user. If the site has no binds, returns UID for "apache". If the site is namedSite.DISABLED
, always returns UID for "apache".- Throws:
IOException
SQLException
-
getRejectedLocations
public Map<String,List<HttpdSiteManager.Location>> getRejectedLocations() throws IOException, SQLExceptionGets an unmodifiable map of URL patterns that should be rejected.- Throws:
IOException
SQLException
-
getPermanentRewriteRules
Gets the set of permanent rewrite rules. By default, no rules. -
blockAllTraceAndTrackRequests
public boolean blockAllTraceAndTrackRequests()By default, sites will block all TRACE and TRACK requests.Seriously consider security ramifications before enabling TRACK and TRACE.
- See Also:
-
getJkSettings
Gets the JkMount and JkUnmounts for this site.This default implementation returns an empty set.
- Returns:
- An empty set if no Jk enabled.
- Throws:
IOException
SQLException
-
getWebapps
public abstract SortedMap<String,HttpdSiteManager.WebAppSettings> getWebapps() throws IOException, SQLExceptionGets all the webapps for this site. The key is the webapp path and the value is the settings for that path. If any webapp enables CGI, then this site overall must allow CGI.- Throws:
IOException
SQLException
-