summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/server
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-12-18 20:19:11 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-12-18 20:19:11 +0000
commit3ac8ca7868ade978a3d0fc74113f3276e5c183ec (patch)
treebcec824aaee082426af297c1ebc331b98c25824f /sca-cpp/trunk/modules/server
parent0498e9dd768e270b74045acd96075306c29a9b4a (diff)
Add ability to configure an HTTPS proxy with load balancing over a set of HTTP backend servers and get OAuth authentication working with that topology.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1220526 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/server')
-rw-r--r--sca-cpp/trunk/modules/server/mod-eval.hpp22
-rw-r--r--sca-cpp/trunk/modules/server/mod-wiring.cpp23
-rwxr-xr-xsca-cpp/trunk/modules/server/server-conf4
3 files changed, 43 insertions, 6 deletions
diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp
index 4c305fccbf..31e850d18c 100644
--- a/sca-cpp/trunk/modules/server/mod-eval.hpp
+++ b/sca-cpp/trunk/modules/server/mod-eval.hpp
@@ -56,10 +56,10 @@ namespace modeval {
*/
class ServerConf {
public:
- ServerConf(apr_pool_t* p, server_rec* s) : p(p), server(s), contributionPath(""), compositeName(""), virtualHostContributionPath(""), virtualHostCompositeName(""), ca(""), cert(""), key("") {
+ ServerConf(apr_pool_t* p, server_rec* s) : p(p), server(s), contributionPath(""), compositeName(""), virtualHostDomain(""), virtualHostContributionPath(""), virtualHostCompositeName(""), ca(""), cert(""), key("") {
}
- ServerConf(apr_pool_t* p, const ServerConf& ssc, const string& name) : p(p), server(ssc.server), lifecycle(ssc.lifecycle), contributionPath(ssc.virtualHostContributionPath + name + "/"), compositeName(ssc.virtualHostCompositeName), virtualHostContributionPath(""), virtualHostCompositeName(""), ca(ssc.ca), cert(ssc.cert), key(ssc.key) {
+ ServerConf(apr_pool_t* p, const ServerConf& ssc, const string& name) : p(p), server(ssc.server), lifecycle(ssc.lifecycle), contributionPath(ssc.virtualHostContributionPath + name + "/"), compositeName(ssc.virtualHostCompositeName), virtualHostDomain(""), virtualHostContributionPath(""), virtualHostCompositeName(""), ca(ssc.ca), cert(ssc.cert), key(ssc.key) {
}
const gc_pool p;
@@ -67,6 +67,7 @@ public:
lambda<value(const list<value>&)> lifecycle;
string contributionPath;
string compositeName;
+ string virtualHostDomain;
string virtualHostContributionPath;
string virtualHostCompositeName;
string ca;
@@ -84,6 +85,13 @@ const bool hasCompositeConf(const ServerConf& sc) {
}
/**
+ * Return true if a server contains a virtual host domain configuration.
+ */
+const bool hasVirtualDomainConf(const ServerConf& sc) {
+ return sc.virtualHostDomain != "";
+}
+
+/**
* Return true if a server contains a virtual host composite configuration.
*/
const bool hasVirtualCompositeConf(const ServerConf& sc) {
@@ -812,7 +820,7 @@ const int handleRequest(const ServerConf& sc, const list<value>& rpath, request_
// Handle a request targeting a virtual host or virtual app
if (hasVirtualCompositeConf(sc)) {
- if (httpd::isVirtualHostRequest(sc.server, r)) {
+ if (hasVirtualDomainConf(sc) && httpd::isVirtualHostRequest(sc.server, sc.virtualHostDomain, r)) {
ServerConf vsc(r->pool, sc, http::subDomain(httpd::hostName(r)));
if (!hasContent(virtualHostConfig(vsc, sc, r)))
return HTTP_INTERNAL_SERVER_ERROR;
@@ -916,6 +924,7 @@ const int postConfigMerge(const ServerConf& mainsc, server_rec* s) {
sc.lifecycle = mainsc.lifecycle;
sc.contributionPath = mainsc.contributionPath;
sc.compositeName = mainsc.compositeName;
+ sc.virtualHostDomain = mainsc.virtualHostDomain;
sc.virtualHostContributionPath = mainsc.virtualHostContributionPath;
sc.virtualHostCompositeName = mainsc.virtualHostCompositeName;
if (sc.ca == "") sc.ca = mainsc.ca;
@@ -1026,6 +1035,12 @@ const char* confComposite(cmd_parms *cmd, unused void *c, const char *arg) {
sc.compositeName = arg;
return NULL;
}
+const char* confVirtualDomain(cmd_parms *cmd, unused void *c, const char *arg) {
+ gc_scoped_pool pool(cmd->pool);
+ ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_eval);
+ sc.virtualHostDomain = arg;
+ return NULL;
+}
const char* confVirtualContribution(cmd_parms *cmd, unused void *c, const char *arg) {
gc_scoped_pool pool(cmd->pool);
ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_eval);
@@ -1068,6 +1083,7 @@ const char* confEnv(unused cmd_parms *cmd, unused void *c, const char *name, con
const command_rec commands[] = {
AP_INIT_TAKE1("SCAContribution", (const char*(*)())confContribution, NULL, RSRC_CONF, "SCA contribution location"),
AP_INIT_TAKE1("SCAComposite", (const char*(*)())confComposite, NULL, RSRC_CONF, "SCA composite location"),
+ AP_INIT_TAKE1("SCAVirtualDomain", (const char*(*)())confVirtualDomain, NULL, RSRC_CONF, "SCA virtual host domain"),
AP_INIT_TAKE1("SCAVirtualContribution", (const char*(*)())confVirtualContribution, NULL, RSRC_CONF, "SCA virtual host contribution location"),
AP_INIT_TAKE1("SCAVirtualComposite", (const char*(*)())confVirtualComposite, NULL, RSRC_CONF, "SCA virtual composite location"),
AP_INIT_TAKE12("SCASetEnv", (const char*(*)())confEnv, NULL, OR_FILEINFO, "Environment variable name and optional value"),
diff --git a/sca-cpp/trunk/modules/server/mod-wiring.cpp b/sca-cpp/trunk/modules/server/mod-wiring.cpp
index 39e43c0420..c61e90a6a1 100644
--- a/sca-cpp/trunk/modules/server/mod-wiring.cpp
+++ b/sca-cpp/trunk/modules/server/mod-wiring.cpp
@@ -54,16 +54,17 @@ const bool useModProxy = true;
*/
class ServerConf {
public:
- ServerConf(apr_pool_t* p, server_rec* s) : p(p), server(s), contributionPath(""), compositeName(""), virtualHostContributionPath(""), virtualHostCompositeName("") {
+ ServerConf(apr_pool_t* p, server_rec* s) : p(p), server(s), contributionPath(""), compositeName(""), virtualHostDomain(""), virtualHostContributionPath(""), virtualHostCompositeName("") {
}
- ServerConf(apr_pool_t* p, const ServerConf& ssc, const string& name) : p(p), server(ssc.server), contributionPath(ssc.virtualHostContributionPath + name + "/"), compositeName(ssc.virtualHostCompositeName), virtualHostContributionPath(""), virtualHostCompositeName("") {
+ ServerConf(apr_pool_t* p, const ServerConf& ssc, const string& name) : p(p), server(ssc.server), contributionPath(ssc.virtualHostContributionPath + name + "/"), compositeName(ssc.virtualHostCompositeName), virtualHostDomain(""), virtualHostContributionPath(""), virtualHostCompositeName("") {
}
const gc_pool p;
server_rec* server;
string contributionPath;
string compositeName;
+ string virtualHostDomain;
string virtualHostContributionPath;
string virtualHostCompositeName;
list<value> references;
@@ -78,6 +79,13 @@ const bool hasCompositeConf(const ServerConf& sc) {
}
/**
+ * Return true if a server contains a virtual host domain configuration.
+ */
+const bool hasVirtualDomainConf(const ServerConf& sc) {
+ return sc.virtualHostDomain != "";
+}
+
+/**
* Return true if a server contains a virtual host composite configuration.
*/
const bool hasVirtualCompositeConf(const ServerConf& sc) {
@@ -304,8 +312,9 @@ const int translateRequest(const ServerConf& sc, request_rec *r, const list<valu
// If the request is targeting a virtual host, use the corresponding
// virtual host configuration
+ const bool vdc = hasVirtualDomainConf(sc);
const bool vcc = hasVirtualCompositeConf(sc);
- if (vcc && httpd::isVirtualHostRequest(sc.server, r)) {
+ if (vdc && vcc && httpd::isVirtualHostRequest(sc.server, sc.virtualHostDomain, r)) {
ServerConf vsc(r->pool, sc, http::subDomain(httpd::hostName(r)));
if (!hasContent(virtualHostConfig(vsc, sc, r)))
return HTTP_INTERNAL_SERVER_ERROR;
@@ -409,6 +418,7 @@ const int postConfigMerge(const ServerConf& mainsc, server_rec* s) {
ServerConf& sc = httpd::serverConf<ServerConf>(s, &mod_tuscany_wiring);
sc.contributionPath = mainsc.contributionPath;
sc.compositeName = mainsc.compositeName;
+ sc.virtualHostDomain = mainsc.virtualHostDomain;
sc.virtualHostContributionPath = mainsc.virtualHostContributionPath;
sc.virtualHostCompositeName = mainsc.virtualHostCompositeName;
sc.references = mainsc.references;
@@ -462,6 +472,12 @@ const char *confComposite(cmd_parms *cmd, unused void *c, const char *arg) {
sc.compositeName = arg;
return NULL;
}
+const char *confVirtualDomain(cmd_parms *cmd, unused void *c, const char *arg) {
+ gc_scoped_pool pool(cmd->pool);
+ ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_wiring);
+ sc.virtualHostDomain = arg;
+ return NULL;
+}
const char *confVirtualContribution(cmd_parms *cmd, unused void *c, const char *arg) {
gc_scoped_pool pool(cmd->pool);
ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_wiring);
@@ -481,6 +497,7 @@ const char *confVirtualComposite(cmd_parms *cmd, unused void *c, const char *arg
const command_rec commands[] = {
AP_INIT_TAKE1("SCAContribution", (const char*(*)())confContribution, NULL, RSRC_CONF, "SCA contribution location"),
AP_INIT_TAKE1("SCAComposite", (const char*(*)())confComposite, NULL, RSRC_CONF, "SCA composite location"),
+ AP_INIT_TAKE1("SCAVirtualDomain", (const char*(*)())confVirtualDomain, NULL, RSRC_CONF, "SCA virtual host domain"),
AP_INIT_TAKE1("SCAVirtualContribution", (const char*(*)())confVirtualContribution, NULL, RSRC_CONF, "SCA virtual host contribution location"),
AP_INIT_TAKE1("SCAVirtualComposite", (const char*(*)())confVirtualComposite, NULL, RSRC_CONF, "SCA virtual host composite location"),
{NULL, NULL, NULL, 0, NO_ARGS, NULL}
diff --git a/sca-cpp/trunk/modules/server/server-conf b/sca-cpp/trunk/modules/server/server-conf
index 5b3024abbc..47934f973e 100755
--- a/sca-cpp/trunk/modules/server/server-conf
+++ b/sca-cpp/trunk/modules/server/server-conf
@@ -54,6 +54,10 @@ Alias /scdl.js $jsprefix/htdocs/scdl.js
Alias /all.js $jsprefix/htdocs/all.js
Alias /all-min.js $jsprefix/htdocs/all-min.js
+EOF
+
+cat >>$root/conf/pubauth.conf <<EOF
+# Generated by: server-conf $*
<Location /component.js>
AuthType None
Require all granted