简体   繁体   中英

Running Proxy servlet on Openshift

This app http://bit.ly/1vNUIsU originally worked with Openshift, after deleting the app, then re-creating, its not working anymore, its very odd. The same code worked before. Not sure what happened.

In any case, I've tried everything, rhc app-tidy and rhc tail but the app just keeps loading

Error 503 when accessed. 

I am not sure if the issue is with Restlet as it worked before. What could be the issues of Restlet with Openshift just in case?

Code:

public class FirstStepsApplication extends Application {
    private static final String ROOT_URI = "/";
    @Override
    public Restlet createInboundRoot() {
        Router router = new Router(getContext());
        Redirector proxy = new Redirector(getContext(), Constants.root,
                Redirector.MODE_SERVER_OUTBOUND){
            @Override
            public void handle(Request request, Response response) {
                String path = request.getResourceRef().getHostIdentifier() +
                        request.getResourceRef().getPath();
                try {
                    URL url = new URL(path);
                    String host = url.getHost();
                    String pathParts = url.getPath();
                    if(pathParts.isEmpty() || pathParts.equals(ROOT_URI)){
                        pathParts = "/index.html";
                    }
                    String targetPattern = Constants.root + host + pathParts;
                    System.out.println("Target URL = " + targetPattern);
                    this.setTargetTemplate(targetPattern);
                } catch (MalformedURLException e){
                    e.printStackTrace();
                }
                super.handle(request, response);
            }
        };
        getConnectorService().getClientProtocols().add(Protocol.HTTP);
        router.attachDefault(proxy);
        return router;
    }
}

This code worked with Opensift/JBoss before. Not it wont.

我设法使其与Tomcat 7 Cartridge而不是JBoss / Capedwarf一起使用

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM