Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenShift - How to redirect an $url/$path into an $url

I'm asking a question which is probably easy when you know how to do it, but I still did not manage after many tries.

I've got a JavaEE website accessible at the URL: http://siteperso-valentin.1d35.starter-us-east-1.openshiftapps.com/sitePerso/

But I would like it to be accessible directly at http://siteperso-valentin.1d35.starter-us-east-1.openshiftapps.com/ without the sitePerso.

For that, in my Openshift account, I've got a route which is as follow:

apiVersion: route.openshift.io/v1
kind: Route
metadata:
  annotations:
    openshift.io/host.generated: 'true'
  creationTimestamp: '2018-02-18T14:00:04Z'
  labels:
    app: siteperso
  name: siteperso
  namespace: valentin
  resourceVersion: '2416325777'
  selfLink: /apis/route.openshift.io/v1/namespaces/valentin/routes/siteperso
  uid: ********
spec:
  host: siteperso-valentin.1d35.starter-us-east-1.openshiftapps.com
  path: /sitePerso/
  port:
    targetPort: 8080-tcp
  to:
    kind: Service
    name: siteperso
    weight: 100
  wildcardPolicy: None
status:
  ingress:
    - conditions:
        - lastTransitionTime: '2018-02-18T14:00:04Z'
          status: 'True'
          type: Admitted
      host: siteperso-valentin.1d35.starter-us-east-1.openshiftapps.com
      routerCanonicalHostname: elb.1d35.starter-us-east-1.openshiftapps.com
      routerName: router
      wildcardPolicy: None

I would assume I need another route to somehow make "invisible" the sitePerso, but I don't manage to it.

Thanks in advance for your help,

like image 632
Valentin Montmirail Avatar asked Oct 17 '25 13:10

Valentin Montmirail


2 Answers

There is no way in a Route to manipulate the URL as it passes through. The path setting only indicates whether URLs for that sub path should be matched by that route and passed through, it doesn't change the URL.

If you can't just change your application to mount the application at the root of the site instead of a sub URL, you are going to have to deploy your own proxy in front, inside of OpenShift, which can do the URL rewriting for you.

like image 70
Graham Dumpleton Avatar answered Oct 21 '25 00:10

Graham Dumpleton


If you're using one of the OpenShift JWS/Tomcat builder images and you'd like your app/site to be available in the root context, please make sure to use the ROOT.war name for the war file that is to be deployed.

Other names are deployed under the respective context, that is <route_url>/sitePerso in case of the sitePerso.war that you're using for binary deployment.

So basically, changing the war's name into ROOT.warfixed the problem.

like image 41
Valentin Montmirail Avatar answered Oct 21 '25 00:10

Valentin Montmirail