[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Handle-info] Adding pages to handle server: FastCGI proxy vs. upstream webserver vs. Java implementation



Dear all,

at our institution, we would like to provide additional landing pages via our handle server. I.e., a kind of proxy server application that runs on the handle server outside of the institutions network, and has access to certain services behind the firewall and can gather information/static pages from them.

We already have a basic PHP implementation that I wrote before it was clear that we would use the handle server for this task. Moreover, no-one in our team is too familiar with Java (apart from little projects back in university). So we were wondering whether it was possible to use the PHP application together with the handle.net software.

My first idea was to run both applications behind another web server (like nginx) but it turned out this isn't trivial due to encryption, authentication and the handle server using both TCP and UDP. So I abandoned the idea.

Since Jetty offers a FastCGI proxy library, and the handle manual explicitly says that the embedded Jetty can be further configured, I thought it should be possible to embed our PHP application this way. I dropped a simple PHP script (attachment) into /var/www/html and, guided by error messages and the Jetty manual, created a jetty.xml config file (attachment). I also added Jetty's fcgi-server.jar and jetty-proxy.jar v9.4.15 to the lib/servletContainer directory. Using this configuration, the server starts up just fine. However, accessing / results in HTTP/404 and /php-test/info.php results in HTTP/400, telling me the handle could not be resolved. So it seems some of the endpoints/servlets/handlers (I'm not sure about the Jetty terminology here) were overwritten while others were not. Please find attached the access and error logs. (Note: I ran the server locally on port 8443; IP is redacted.) I would be grateful if someone could help me get this up and running. I tried Stack Overflow already as this feels more like a general Jetty question that is not specific to handle.net. However, in typical Stack Overflow fashion, the only response I received was someone telling me off for still using Jetty 9 which is EOL. 😄

Finally, there's of course the option to implement our solution in Java. Though I'm not sure whether this solves the problem.

Thank you in advance and have a great week!

Kind regards
David Pape

--
David Pape

Research Software Engineer
Data Management and HPC Group (FWCC-D)
Computational Science Department (FWCC)
Department of Information Services and Computing (FWC)
Building 312, Room 3
Helmholtz-Zentrum Dresden-Rossendorf e.V.
Bautzner Landstr. 400 | 01328 Dresden | Germany
Phone: +49 - 351 - 260 3808
https://www.hzdr.de

Board of Directors: Prof. Dr. Sebastian M. Schmidt, Dr. Diana Stiller
Company Registration Number VR 1693, Amtsgericht Dresden
XXX.XXX.XXX.XXX HTTP:HDLProxy "2023-08-07 09:15:37.102+0200" 1 301 0ms  php-test/info.php
"2023-08-07 09:15:20.586+0200" 25 Started new run.
"2023-08-07 09:15:20.588+0200" 25 Handle.net Server Software version 9.3.0
"2023-08-07 09:15:21.024+0200" 25 Warning: certificate key from serverCertificate.pem does not match server key
Opening Berkeley database in /opt/handle/handle_svr_1/bdbje
2023-08-07 09:15:21.393+0200 [main] INFO org.eclipse.jetty.util.log - Logging initialized @1433ms to org.eclipse.jetty.util.log.Slf4jLog
2023-08-07 09:15:21.611+0200 [main] INFO org.eclipse.jetty.deploy.providers.ScanningAppProvider - Deployment monitor [file:///opt/handle/handle_svr_1/webapps-priority] at interval 10
2023-08-07 09:15:21.611+0200 [main] WARN org.eclipse.jetty.deploy.providers.ScanningAppProvider - Does not exist: file:///opt/handle/handle_svr_1/webapps-priority
2023-08-07 09:15:21.614+0200 [main] INFO org.eclipse.jetty.server.Server - jetty-9.4.15.v20190215; built: 2019-02-15T16:53:49.381Z; git: eb70b240169fcf1abbd86af36482d1c49826fa0b; jvm 17.0.7+7
2023-08-07 09:15:21.625+0200 [main] INFO org.eclipse.jetty.server.session - DefaultSessionIdManager workerName=node0
2023-08-07 09:15:21.626+0200 [main] INFO org.eclipse.jetty.server.session - No SessionScavenger set, using defaults
2023-08-07 09:15:21.627+0200 [main] INFO org.eclipse.jetty.server.session - node0 Scavenging every 660000ms
2023-08-07 09:15:21.650+0200 [main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@2db2cd5{/,jar:file:/opt/handle/handle-9.3.0/lib/handle-9.3.0.jar!/net/handle/apps/servlet_proxy/resources/,AVAILABLE}
2023-08-07 09:15:21.652+0200 [main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@323e8306{/php-test,file:///var/www/html/,AVAILABLE}
2023-08-07 09:15:21.656+0200 [main] WARN org.eclipse.jetty.util.ssl.SslContextFactory.config - No Client EndPointIdentificationAlgorithm configured for SslContextFactory@47a64f7d[provider=null,keyStore=null,trustStore=null]
2023-08-07 09:15:21.668+0200 [main] INFO org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@437e951d{ssl|other,[ssl|other, ssl, http/1.1]}{XXX.XXX.XXX.XXX:8443}
2023-08-07 09:15:21.669+0200 [main] INFO org.eclipse.jetty.server.Server - Started @1709ms
2023-08-07 09:15:21.669+0200 [main] INFO org.eclipse.jetty.deploy.providers.ScanningAppProvider - Deployment monitor [file:///opt/handle/handle_svr_1/webapps/] at interval 10
2023-08-07 09:15:21.931+0200 [main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@4837595f{admin,/admin,file:///opt/handle/handle_svr_1/webapps-temp/jetty-XXX.XXX.XXX.XXX-8443-admin.war-_admin-any-18367378990823993116.dir/webapp/,AVAILABLE}{/admin.war}
"2023-08-07 09:15:41.046+0200" 25 Shutting down server at Mon Aug 07 09:15:41 CEST 2023
2023-08-07 09:15:41.081+0200 [Thread-24] INFO org.eclipse.jetty.server.handler.ContextHandler - Stopped o.e.j.w.WebAppContext@4837595f{admin,/admin,null,UNAVAILABLE}{/admin.war}
2023-08-07 09:15:41.085+0200 [Thread-24] INFO org.eclipse.jetty.server.AbstractConnector - Stopped ServerConnector@437e951d{ssl|other,[ssl|other, ssl, http/1.1]}{XXX.XXX.XXX.XXX:8443}
2023-08-07 09:15:41.085+0200 [Thread-24] INFO org.eclipse.jetty.server.session - node0 Stopped scavenging
2023-08-07 09:15:41.086+0200 [Thread-24] INFO org.eclipse.jetty.server.handler.ContextHandler - Stopped o.e.j.s.ServletContextHandler@2db2cd5{/,jar:file:/opt/handle/handle-9.3.0/lib/handle-9.3.0.jar!/net/handle/apps/servlet_proxy/resources/,UNAVAILABLE}
2023-08-07 09:15:41.086+0200 [Thread-24] INFO org.eclipse.jetty.server.handler.ContextHandler - Stopped o.e.j.s.ServletContextHandler@323e8306{/php-test,file:///var/www/html/,UNAVAILABLE}

Attachment: info.php
Description: application/php

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd";>

<Configure id="Server" class="org.eclipse.jetty.server.Server">

  <New id="root" class="java.lang.String"><Arg>/var/www/html</Arg></New>
  <New id="prefix" class="java.lang.String"><Arg>/php-test</Arg></New>
  <New id="fpmSocket" class="java.lang.String"><Arg>http://127.0.0.1:9000</Arg></New>

  <New id="FastCGIProxyHandler" class="org.eclipse.jetty.servlet.ServletContextHandler">

    <Set name="contextPath"><Ref refid="prefix" /></Set>
    <Set name="resourceBase"><Ref refid="root" /></Set>
    <Set name="welcomeFiles">
        <Array type="string">
          <Item>info.php</Item>
          <Item>index.php</Item>
          <Item>index.html</Item>
          <Item>index.htm</Item>
        </Array>
    </Set>

    <Call name="addServlet">
      <Arg>org.eclipse.jetty.fcgi.server.proxy.FastCGIProxyServlet</Arg>
      <Arg><Ref refid="prefix" /></Arg>
      <Call name="setInitParameter">
        <Arg>proxyTo</Arg>
        <Arg><Ref refid="fpmSocket" /></Arg>
      </Call>
      <Call name="setInitParameter">
        <Arg>prefix</Arg>
        <Arg><Ref refid="prefix" /></Arg>
      </Call>
      <Call name="setInitParameter">
        <Arg>scriptRoot</Arg>
        <Arg><Ref refid="root" /></Arg>
      </Call>
    </Call>
  </New>

  <Call name="insertHandler">
    <Arg>
      <Ref refid="FastCGIProxyHandler" />
    </Arg>
  </Call>

</Configure>

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
Handle-Info mailing list
Handle-Info@cnri.reston.va.us
http://www.handle.net/mailman/listinfo/handle-info