6 Replies Latest reply on Aug 16, 2016 12:05 PM by James Hayes

    Configure Http Proxy for Wildfly 8.1.0

    norman.rennhack Newbie

      Hi folks,

       

      can someone tell me how to configure a proxy server for my wildfly 8.1.

      The Wildfly Instance is running as standalone on RHEL 6.5.

      The machine has no direct access to the internet but one of the deployed applications should use an existing HTTP proxy (without Authentication) to send messages to google cloud messaging. So somehow I have to tell Wildfly or the application on it to tell where is the Proxy.

      I'm starting/stopping the instance via the default init.d scripts with service wildfly start/stop/restart.

       

      I already did this successfully for an other application, running on a Tomcat instance, by using JAVA_OPTS.

      So first thing I tried was:

       

      Setting the proxy via JAVA_OPTS in standalone.sh

      # Display our environment
      echo "========================================================================="
      echo ""
      echo "  JBoss Bootstrap Environment"
      echo ""
      echo "  JBOSS_HOME: $JBOSS_HOME"
      echo ""
      echo "  JAVA: $JAVA"
      echo ""
      echo "  JAVA_OPTS: $JAVA_OPTS"
      echo ""
      echo "========================================================================="
      echo ""
      
      JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=myproxy -Dhttp.proxyPort=3128"
      
      while true; do
         if [ "x$LAUNCH_JBOSS_IN_BACKGROUND" = "x" ]; then
            # Execute the JVM in the foreground
            eval \"$JAVA\" -D\"[Standalone]\" $JAVA_OPTS  \
               \"-Dorg.jboss.boot.log.file=$JBOSS_LOG_DIR/server.log\" \
               \"-Dlogging.configuration=file:$JBOSS_CONFIG_DIR/logging.properties\" \
               -jar \"$JBOSS_HOME/jboss-modules.jar\" \
               -mp \"${JBOSS_MODULEPATH}\" \
               org.jboss.as.standalone \
               -Djboss.home.dir=\"$JBOSS_HOME\" \
               -Djboss.server.base.dir=\"$JBOSS_BASE_DIR\" \
               "$SERVER_OPTS"
            JBOSS_STATUS=$?
         else
            # Execute the JVM in the background
            eval \"$JAVA\" -D\"[Standalone]\" $JAVA_OPTS \
               \"-Dorg.jboss.boot.log.file=$JBOSS_LOG_DIR/server.log\" \
               \"-Dlogging.configuration=file:$JBOSS_CONFIG_DIR/logging.properties\" \
               -jar \"$JBOSS_HOME/jboss-modules.jar\" \
               -mp \"${JBOSS_MODULEPATH}\" \
               org.jboss.as.standalone \
               -Djboss.home.dir=\"$JBOSS_HOME\" \
               -Djboss.server.base.dir=\"$JBOSS_BASE_DIR\" \
               "$SERVER_OPTS" "&"
            JBOSS_PID=$!
      
      
      
      
      
      

       

      The server boots without errors and running ps aux gives me the wildfly instance having the JAVA_OPTS set correctly. However, in the Application I still get the ConnectionTimedoutException.

       

      Next try:

      Exporting http_proxy and https_proxy environment variable in the standalone.sh

      When I do export http_proxy=myproxy:3128 and export https_proxy=myproxy:3128 and run curl google.com afterwards, it's perfectly working, so the proxy must work. However, adding this command to the standalone.sh seems to have no effect. Still the ConnectionTimedoutException occurs for my application.

       

      # Display our environment
      echo "========================================================================="
      echo ""
      echo "  JBoss Bootstrap Environment"
      echo ""
      echo "  JBOSS_HOME: $JBOSS_HOME"
      echo ""
      echo "  JAVA: $JAVA"
      echo ""
      echo "  JAVA_OPTS: $JAVA_OPTS"
      echo ""
      echo "========================================================================="
      echo ""
      
      http_proxy=myproxy:3128
      https_proxy=myproxy:3128
      export http_proxy
      export https_proxy
      
      while true; do
         if [ "x$LAUNCH_JBOSS_IN_BACKGROUND" = "x" ]; then
            # Execute the JVM in the foreground
            eval \"$JAVA\" -D\"[Standalone]\" $JAVA_OPTS  \
               \"-Dorg.jboss.boot.log.file=$JBOSS_LOG_DIR/server.log\" \
               \"-Dlogging.configuration=file:$JBOSS_CONFIG_DIR/logging.properties\" \
               -jar \"$JBOSS_HOME/jboss-modules.jar\" \
               -mp \"${JBOSS_MODULEPATH}\" \
               org.jboss.as.standalone \
               -Djboss.home.dir=\"$JBOSS_HOME\" \
               -Djboss.server.base.dir=\"$JBOSS_BASE_DIR\" \
               "$SERVER_OPTS"
            JBOSS_STATUS=$?
         else
            # Execute the JVM in the background
            eval \"$JAVA\" -D\"[Standalone]\" $JAVA_OPTS \
               \"-Dorg.jboss.boot.log.file=$JBOSS_LOG_DIR/server.log\" \
               \"-Dlogging.configuration=file:$JBOSS_CONFIG_DIR/logging.properties\" \
               -jar \"$JBOSS_HOME/jboss-modules.jar\" \
               -mp \"${JBOSS_MODULEPATH}\" \
               org.jboss.as.standalone \
               -Djboss.home.dir=\"$JBOSS_HOME\" \
               -Djboss.server.base.dir=\"$JBOSS_BASE_DIR\" \
               "$SERVER_OPTS" "&"
            JBOSS_PID=$!
      
      

       

       

      Thanks in advance for any comments!

       

      Added some details