Results 1 to 4 of 4

Thread: How to run z-push on zimbra jetty: Proof of Concept

  1. #1
    speedy3k is offline Intermediate Member
    Join Date
    Sep 2009
    Posts
    21
    Rep Power
    5

    Default How to run z-push on zimbra jetty: Proof of Concept

    This is a proof of concept for getting z-push to run on the same server as zimbra without doing too much. It was late when I did this, so I may have missed a step or two. There probably is even a better way to do this! Also, this is only a proof of concept. Future updates will probably break it. As always, use at your own risk!

    This was tested using z-push 2.0.8-1731, zimbrabackend 56.1, Zimbra 8.0.4 OSE on Centos6

    install php-cgi php-process

    :create folder
    opt/z-push and copy z-push files to it
    Configure z-push per install instructions. zimbra url for backend can be localhost or 127.0.0.1

    :create link in opt/zimbra/jetty/webapps to /opt/z-push
    ln -s /opt/zimbra/jetty/webapps/z-push /opt/z-push

    :create shell file called php-cgi-fix.sh in /usr/bin
    #/usr/bin/sh
    export SCRIPT_FILENAME=$1
    /usr/bin/php-cgi

    :create a WEB-INF folder in /opt/z-push

    :create web.xml file with the following info and place in /opt/z-push/WEB-INF
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
        <web-app
          xmlns="http://java.sun.com/xml/ns/j2ee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
          version="2.4"
        >
    
         <display-name>php</display-name>
    
         <servlet>
           <servlet-name>PHP</servlet-name>
           <servlet-class>org.eclipse.jetty.servlets.CGI</servlet-class>
           <load-on-startup>1</load-on-startup>
    
           <init-param>
                <param-name>commandPrefix</param-name>
                <param-value>/usr/bin/php-cgi-fix.sh</param-value>
           </init-param>
    
              <init-param>
                  <param-name>Path</param-name>
                  <param-value>/bin:/usr/bin:/usr/local/bin</param-value>
              </init-param>
            
         </servlet>
    
         <servlet-mapping>
           <servlet-name>PHP</servlet-name>
           <url-pattern>*.php</url-pattern>
         </servlet-mapping>
    
         <!--
         <welcome-file-list>
           <welcome-file>index.php</welcome-file>
         </welcome-file-list>
         -->
    
    <Call name="addAliasCheck">
        <Arg>
          <New class="org.eclipse.jetty.server.handler.ContextHandler$ApprovePathPrefixAliases"/>
        </Arg>
      </Call>
    
    <security-constraint>
            <web-resource-collection>
                <web-resource-name>deny</web-resource-name>
                <url-pattern>/backend/*</url-pattern>
    	    <url-pattern>/include/*</url-pattern>
                <url-pattern>/lib/*</url-pattern>
    	    <url-pattern>/WEB-INF/*</url-pattern>
                <url-pattern>/config.php</url-pattern>
                <url-pattern>/z-push-top.php</url-pattern>
                <url-pattern>/z-push-admin.php</url-pattern>
                <url-pattern>/INSTALL</url-pattern>
                <url-pattern>/LICENSE</url-pattern>
            </web-resource-collection>
    	<auth-constraint>
           <role-name>deny</role-name>
        	</auth-constraint>
           </security-constraint>
    </web-app>
    :edit /opt/zimbra/jetty/etc/jetty.xml.in
    Find
    Code:
                <Set name="replacement">/service/extension/zimbrasync</Set>
    Change
    Code:
                 <Set name="replacement">/z-push/index.php</Set>
    Add
    I added this below a similar entry for "zimlet"
    Code:
    <Call name="addRule">
    	    <Arg>        
    		<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
    		    <Set name="pattern">/z-push/*</Set>
    		    <Set name="replacement">/z-push</Set>
    		    <Set name="terminating">true</Set>
    		</New>
    	    </Arg>
            </Call>
    Add
    Again, I added this near similar code for "zimlet"
    Code:
    <New id="z-push" class="org.eclipse.jetty.webapp.WebAppContext">
          <Arg><Ref id="Contexts"/></Arg>
          <Arg><SystemProperty name="jetty.home" default="."/>/webapps/z-push</Arg>
          <Arg>/z-push</Arg>
          <Set name="configurationClasses"><Ref id="plusConfig"/></Set>
          <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
          <Set name="tempDirectory"><SystemProperty name="jetty.home" default="."/>/work/z-push</Set>
          <Set name="compactPath">true</Set>
          <Get name="errorHandler">
            <Call name="setShowStacks">
              <Arg type="boolean">false</Arg>
            </Call>
          </Get>
          <Call name="setAttribute">
            <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
    		<Arg>.*/.*jsp-api-[^/]*\.jar$|.*/.*jsp-[^/]*\.jar$|.*/.*taglibs[^/]*\.jar$</Arg>
          </Call> 
        </New>
    :Edit php.ini
    edit etc/php.ini
    magic_quotes_gpc off
    register_globals off
    magic_quotes_runtime off
    short_open_tag on
    cgi.force_redirect = 0
    max_execution_time = 120
    memory_limit = 128M

    :restart jetty
    su zimbra
    zmmailboxdctl restart

    That should do it.
    I welcome any feedback/suggestions. Please let me know if you have any questions, and I'll do my best to answer them.
    Last edited by speedy3k; 09-02-2013 at 11:06 AM.

  2. #2
    davidsalgadolinux is offline Starter Member
    Join Date
    Sep 2013
    Posts
    1
    Rep Power
    1

    Default

    Hi !
    It works !
    Just check the shell script

    :create shell file called php-cgi-fix.sh in /usr/bin
    #/usr/bin/sh
    export SCRIPT_FILENAME=$1
    /usr/bin/php-cgi

    Would' t the first line be:

    #!/bin/sh

    ??

    Thanks your work allowed me to use Outlook 2013 like this:

    How to connect Exchange ActiveSync (Z-Push or other EAS Server) with Outlook 2013 - iFix4You Repair and Services

    Since we just had http on port :80

    Bye !

  3. #3
    speedy3k is offline Intermediate Member
    Join Date
    Sep 2009
    Posts
    21
    Rep Power
    5

    Default

    update:
    I'm now running this using fastcgi If anyone is interested, in trying this out..just do the following. (this is assuming you already have following the steps in my first post)
    download jfastcgi
    jFastCGI | Free software downloads at SourceForge.net

    place jfastcgi.jar in /opt/z-push/WEB-INF/lib
    rename your web.xml to web.xml.bak (or whatever)
    create a new new web.xml using the following
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
        <web-app
          xmlns="http://java.sun.com/xml/ns/j2ee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
          version="2.4"
        >
    
         <display-name>php</display-name>
    
            <servlet>
            <servlet-name>FastCGI</servlet-name>
            <servlet-class>net.jr.fastcgi.FastCGIServlet</servlet-class>
            <init-param>
              <param-name>server-address</param-name>
              <param-value>127.0.0.1:6666</param-value>
            </init-param>
            <load-on-startup>5</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>FastCGI</servlet-name>
            <url-pattern>*.php</url-pattern>
        </servlet-mapping>
         
    <!-- If you want http://yourhost/yourapp to call yourapp/yourapp.php then make a welcome file -->
         <!--
         <welcome-file-list>
           <welcome-file>index.php</welcome-file>
         </welcome-file-list>
         -->
    
    <security-constraint>
            <web-resource-collection>
                <web-resource-name>deny</web-resource-name>
                <url-pattern>/backend/*</url-pattern>
    	     <url-pattern>/include/*</url-pattern>
                <url-pattern>/lib/*</url-pattern>
    	     <url-pattern>/WEB-INF/*</url-pattern>
                <url-pattern>/config.php</url-pattern>
                <url-pattern>/z-push-top.php</url-pattern>
                <url-pattern>/z-push-admin.php</url-pattern>
                <url-pattern>/INSTALL</url-pattern>
                <url-pattern>/LICENSE</url-pattern>
            </web-resource-collection>
    	<auth-constraint>
           <role-name>deny</role-name>
        	</auth-constraint>
           </security-constraint>
    </web-app>
    **note...I'm not sure if the security-constraint is needed or not, but I figured better safe than sorry.

    Thats it. restart your services

    Let me know if you have any questions and I'll do my best to help.
    Last edited by speedy3k; 01-31-2014 at 10:42 AM.

  4. #4
    svalavuo is offline New Member
    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    6

    Default

    Is it possible to get this working with ubuntu?
    There is no php-process -package.
    I got ActiveSync working with apache, but can't get it to work with jetty so I must access it through different hostname.
    It would be great to use my zimbra host (and jetty) with my mobile too.
    When I access my host with url Microsoft-Server-ActiveSync, it asks credentials and then it displays:
    Code:
    Problem accessing /z-push/index.php. Reason:
        Failed to exec CGI
    With FastCGI I get following:
    Code:
    Caused by:
    
    java.lang.RuntimeException: java.net.ConnectException: Connection refused
    	at net.jr.fastcgi.impl.SingleConnectionFactory.getConnection(SingleConnectionFactory.java:55)
    	at net.jr.fastcgi.impl.FastCGIHandler.service(FastCGIHandler.java:152)
    	at net.jr.fastcgi.FastCGIServlet.service(FastCGIServlet.java:50)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:654)
    	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:445)
    	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
    	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:556)
    	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
    	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1044)
    	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:372)
    	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189)
    	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:978)
    	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
    	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
    	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    	at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:317)
    	at org.eclipse.jetty.server.handler.DebugHandler.handle(DebugHandler.java:81)
    	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    	at org.eclipse.jetty.server.Server.handle(Server.java:369)
    	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:486)
    	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:933)
    	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:995)
    	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
    	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
    	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
    	at org.eclipse.jetty.io.nio.SslConnection.handle(SslConnection.java:196)
    	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
    	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
    	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    	at java.lang.Thread.run(Thread.java:744)
    Caused by: java.net.ConnectException: Connection refused
    	at java.net.PlainSocketImpl.socketConnect(Native Method)
    	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    	at java.net.Socket.connect(Socket.java:579)
    	at java.net.Socket.connect(Socket.java:528)
    	at java.net.Socket.<init>(Socket.java:425)
    	at java.net.Socket.<init>(Socket.java:241)
    	at net.jr.fastcgi.impl.SingleConnectionFactory.getConnection(SingleConnectionFactory.java:53)
    	... 32 more
    
    Caused by:
    
    java.net.ConnectException: Connection refused
    	at java.net.PlainSocketImpl.socketConnect(Native Method)
    	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    	at java.net.Socket.connect(Socket.java:579)
    	at java.net.Socket.connect(Socket.java:528)
    	at java.net.Socket.<init>(Socket.java:425)
    	at java.net.Socket.<init>(Socket.java:241)
    	at net.jr.fastcgi.impl.SingleConnectionFactory.getConnection(SingleConnectionFactory.java:53)
    	at net.jr.fastcgi.impl.FastCGIHandler.service(FastCGIHandler.java:152)
    	at net.jr.fastcgi.FastCGIServlet.service(FastCGIServlet.java:50)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:654)
    	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:445)
    	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
    	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:556)
    	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
    	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1044)
    	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:372)
    	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189)
    	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:978)
    	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
    	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
    	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    	at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:317)
    	at org.eclipse.jetty.server.handler.DebugHandler.handle(DebugHandler.java:81)
    	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    	at org.eclipse.jetty.server.Server.handle(Server.java:369)
    	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:486)
    	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:933)
    	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:995)
    	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
    	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
    	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
    	at org.eclipse.jetty.io.nio.SslConnection.handle(SslConnection.java:196)
    	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
    	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
    	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    	at java.lang.Thread.run(Thread.java:744)
    So I guess fascgi.jar doesn't start with zimbra?

    My system is Ubuntu 12.04.4 LTS
    z-push is version SVN AS14 checkout

    The reason I'm using older version of z-push is that with newer version I get all the folders to my mobiles, but none of the emails/content.


    I got it working!
    My error was, that php-cgi has its own php.ini in ubuntu. After I changed that, it started to work.
    Last edited by svalavuo; 03-26-2014 at 02:52 AM. Reason: Got it working! \o/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Chacal, a CardDAV extension for Thunderbird (proof of concept)
    By ewilen in forum CalDAV / CardDAV / iSync
    Replies: 2
    Last Post: 12-13-2013, 09:55 PM
  2. Trial Install for Proof of Concept
    By Monty3038 in forum Installation
    Replies: 2
    Last Post: 02-07-2011, 09:09 AM
  3. Replies: 1
    Last Post: 09-06-2010, 05:45 AM
  4. Replies: 1
    Last Post: 09-06-2010, 05:45 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •