Skip to content

Commit 71cd4ef

Browse files
committed
progress on fronting glassfish with apache #1096 #2657
1 parent 329b9f3 commit 71cd4ef

File tree

7 files changed

+77
-6
lines changed

7 files changed

+77
-6
lines changed

conf/httpd/conf.d/dataverse.conf

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ProxyPass / ajp://localhost:8009/
2+
3+
# From https://wiki.apache.org/httpd/RewriteHTTPToHTTPS
4+
5+
RewriteEngine On
6+
# This will enable the Rewrite capabilities
7+
8+
RewriteCond %{HTTPS} !=on
9+
# This checks to make sure the connection is not already HTTPS
10+
11+
#RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
12+
RewriteRule ^/dvn/api/data-deposit/?(.*) https://%{SERVER_NAME}/dvn/api/data-deposit/$1 [R,L]
13+
# This rule will redirect users from their original location, to the same location but using HTTPS.
14+
# i.e. http://www.example.com/foo/ to https://www.example.com/foo/
15+
# The leading slash is made optional so that this will work either in httpd.conf
16+
# or .htaccess context
17+
18+
# [#GLASSFISH-20694] Glassfish 4.0 and jk Unable to populate SSL attributes - Java.net JIRA - https://java.net/jira/browse/GLASSFISH-20694
19+
#SSLOptions +StdEnvVars +ExportCertData

scripts/api/data-deposit/pipeline

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env ruby
2+
require "rexml/document"
3+
include REXML
4+
service_document = Document.new `scripts/api/data-deposit/service-document`
5+
collection = XPath.first(service_document, "//collection/@href")
6+
puts collection
7+
8+
puts "Getting first title from #{collection}"
9+
feed_of_studies = Document.new `scripts/api/data-deposit/show-collection #{collection}`
10+
title = XPath.first(feed_of_studies, "//title")
11+
puts title
+8-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/bash
2+
USERNAME=pete
3+
PASSWORD=$USERNAME
24
if [ -z "$1" ]; then
3-
USERNAME=pete
5+
HOSTNAME=localhost:8181
46
else
5-
USERNAME=$1
7+
HOSTNAME=$1
68
fi
7-
PASSWORD=$USERNAME
8-
curl --insecure -s https://$USERNAME:$PASSWORD@localhost:8181/dvn/api/data-deposit/v1/swordv2/service-document | xmllint -format -
9+
URL=https://$HOSTNAME/dvn/api/data-deposit/v1/swordv2/service-document
10+
echo Retrieving service document from $URL >&2
11+
curl --insecure -u $USERNAME:$PASSWORD $URL \
12+
| xmllint -format -
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
USERNAME=pete
3+
PASSWORD=pete
4+
if [ -z "$1" ]; then
5+
echo "Please provide a URL"
6+
else
7+
URL=$1
8+
fi
9+
curl --insecure -s -u $USERNAME:$PASSWORD $URL
10+
#| xmllint -format -

scripts/installer/glassfish-setup.sh

+3
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ fi
231231

232232
./asadmin $ASADMIN_OPTS create-javamail-resource --mailhost "$SMTP_SERVER" --mailuser "dataversenotify" --fromaddress "do-not-reply@${HOST_ADDRESS}" mail/notifyMailSession
233233

234+
# so we can front with apache httpd ( ProxyPass / ajp://localhost:8009/ )
235+
./asadmin $ASADMIN_OPTS create-network-listener --protocol http-listener-1 --listenerport 8009 --jkenabled true jk-connector
236+
234237
###
235238
# Restart
236239
echo Updates done. Restarting...

scripts/setup/asadmin-setup.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ if [ $SUDO_USER == "vagrant" ]
101101
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo
102102
cd
103103
echo "Installing dependencies via yum"
104-
yum install -y -q java-1.7.0-openjdk-devel postgresql-server apache-maven
104+
yum install -y -q java-1.7.0-openjdk-devel postgresql-server apache-maven httpd mod_ssl
105105
rpm -q postgresql-server
106106
echo "Starting PostgreSQL"
107107
chkconfig postgresql on

src/main/java/edu/harvard/iq/dataverse/api/datadeposit/UrlManager.java

+25-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,32 @@ void processUrl(String url) throws SwordError {
2828
} catch (URISyntaxException ex) {
2929
throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, "Invalid URL syntax: " + url);
3030
}
31+
/**
32+
* @todo: figure out another way to check for http. We used to use
33+
* javaNetUri.getScheme() but now that we are using "ProxyPass /
34+
* ajp://localhost:8009/" in Apache it's always http rather than https.
35+
*
36+
* http://serverfault.com/questions/6128/how-do-i-force-apache-to-use-https-in-conjunction-with-ajp
37+
* http://stackoverflow.com/questions/1685563/apache-webserver-jboss-ajp-connectivity-with-https
38+
* http://stackoverflow.com/questions/12460422/how-do-ensure-that-apache-ajp-to-tomcat-connection-is-secure-encrypted
39+
*/
3140
if (!"https".equals(javaNetUri.getScheme())) {
32-
throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, "https is required but protocol was " + javaNetUri.getScheme());
41+
/**
42+
* @todo figure out how to prevent this stackstrace from showing up
43+
* in Glassfish logs:
44+
*
45+
* Unable to populate SSL attributes
46+
* java.lang.IllegalStateException: SSLEngine is null at
47+
* org.glassfish.grizzly.ssl.SSLSupportImpl
48+
*
49+
* SSLOptions +StdEnvVars +ExportCertData ?
50+
*
51+
* [#GLASSFISH-20694] Glassfish 4.0 and jk Unable to populate SSL
52+
* attributes - Java.net JIRA -
53+
* https://java.net/jira/browse/GLASSFISH-20694
54+
*/
55+
logger.info("https is required but protocol was " + javaNetUri.getScheme());
56+
// throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, "https is required but protocol was " + javaNetUri.getScheme());
3357
}
3458
this.port = javaNetUri.getPort();
3559
String[] urlPartsArray = javaNetUri.getPath().split("/");

0 commit comments

Comments
 (0)