mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-05-06 18:26:28 +02:00
@@ -46,7 +46,7 @@
|
||||
<zip destfile="${target.dir}/scala-${scala.version}/gitbucket_${scala.version}-${gitbucket.version}.war"
|
||||
basedir="${target.dir}/scala-${scala.version}/classes"
|
||||
update = "true"
|
||||
includes="JettyLauncher.class"/>
|
||||
includes="JettyLauncher.class,CustomConnector.class"/>
|
||||
</target>
|
||||
|
||||
<target name="rename" depends="embed">
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
# Bind host
|
||||
#GITBUCKET_HOST=0.0.0.0
|
||||
|
||||
# Server port
|
||||
#GITBUCKET_PORT=8080
|
||||
|
||||
# Force HTTPS scheme
|
||||
#GITBUCKET_HTTPS=false
|
||||
|
||||
# Data directory (GITBUCKET_HOME/gitbucket)
|
||||
#GITBUCKET_HOME=/var/lib/gitbucket
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
# Default values
|
||||
GITBUCKET_PORT=8080
|
||||
GITBUCKET_HOME=/var/lib/gitbucket
|
||||
GITBUCKET_WAR_FILE=/usr/share/gitbucket/lib/gitbucket.war
|
||||
|
||||
@@ -31,9 +30,17 @@ start() {
|
||||
echo -n $"Starting GitBucket server: "
|
||||
|
||||
# Compile statup parameters
|
||||
START_OPTS="--port=${GITBUCKET_PORT}"
|
||||
if [ $GITBUCKET_PORT ]; then
|
||||
START_OPTS="${START_OPTS} --port=${GITBUCKET_PORT}"
|
||||
fi
|
||||
if [ $GITBUCKET_PREFIX ]; then
|
||||
START_OPTS="${START_OPTS} --prefix ${GITBUCKET_PREFIX}"
|
||||
START_OPTS="${START_OPTS} --prefix=${GITBUCKET_PREFIX}"
|
||||
fi
|
||||
if [ $GITBUCKET_HOST ]; then
|
||||
START_OPTS="${START_OPTS} --host=${GITBUCKET_HOST}"
|
||||
fi
|
||||
if [ $GITBUCKET_HTTPS ]; then
|
||||
START_OPTS="${START_OPTS} --https=true"
|
||||
fi
|
||||
|
||||
# Run the Java process
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
@@ -10,17 +13,20 @@ public class JettyLauncher {
|
||||
String host = null;
|
||||
int port = 8080;
|
||||
String contextPath = "/";
|
||||
boolean forceHttps = false;
|
||||
|
||||
for(String arg: args){
|
||||
if(arg.startsWith("--") && arg.contains("=")){
|
||||
for(String arg: args) {
|
||||
if(arg.startsWith("--") && arg.contains("=")) {
|
||||
String[] dim = arg.split("=");
|
||||
if(dim.length >= 2){
|
||||
if(dim[0].equals("--host")){
|
||||
if(dim.length >= 2) {
|
||||
if(dim[0].equals("--host")) {
|
||||
host = dim[1];
|
||||
} else if(dim[0].equals("--port")){
|
||||
} else if(dim[0].equals("--port")) {
|
||||
port = Integer.parseInt(dim[1]);
|
||||
} else if(dim[0].equals("--prefix")){
|
||||
} else if(dim[0].equals("--prefix")) {
|
||||
contextPath = dim[1];
|
||||
} else if(dim[0].equals("--https") && (dim[1].equals("1") || dim[1].equals("true"))) {
|
||||
forceHttps = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,8 +34,8 @@ public class JettyLauncher {
|
||||
|
||||
Server server = new Server();
|
||||
|
||||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
if(host != null){
|
||||
CustomConnector connector = new CustomConnector(forceHttps);
|
||||
if(host != null) {
|
||||
connector.setHost(host);
|
||||
}
|
||||
connector.setMaxIdleTime(1000 * 60 * 60);
|
||||
@@ -51,3 +57,19 @@ public class JettyLauncher {
|
||||
server.join();
|
||||
}
|
||||
}
|
||||
|
||||
class CustomConnector extends SelectChannelConnector {
|
||||
boolean mForceHttps;
|
||||
|
||||
public CustomConnector(boolean forceHttps) {
|
||||
mForceHttps = forceHttps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(final EndPoint endpoint, final Request request) throws IOException {
|
||||
if (mForceHttps) {
|
||||
request.setScheme("https");
|
||||
super.customize(endpoint, request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user