Vanity URLs on the IBM i

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
jyoung
Posts: 653
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Vanity URLs on the IBM i

Post by jyoung » Sat Jan 07, 2017 9:44 am

Now that our mobile web app is nearing production status, we are looking at ways of getting to the app easier.

One of those ways is a "vanity" url so that the user goes to ourserver.com/ourapp or ourserver.com/ourapp.html instead of ourserver.com:4580/dcxpgmlib/sys/mobwebapp.html.

I've been doing some research on using vanity urls with apache and my head is spinning in confusion.

I understand that this means we have to have a HTTP Server responding to port 80 in addition to the LANSA Web Server responding on 4580 (which we do). But what I am not understanding is how to get port 80 server to silently (i.e. not change the browser URL) forward the request to the LANSA Web Server.

Has anyone done anything like this? How did you do it?

Thanks,
Joe

dannyoorburg
Posts: 157
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: Vanity URLs on the IBM i

Post by dannyoorburg » Tue Jan 10, 2017 3:57 pm

Hi Joe,

I'm still inclined to create an index.html, as described in:

http://vlforum.lansa.com.au/viewtopic.php?f=4&t=47

so the URL can just be www.myserver.com/myapp and it will default to the index.html inside that folder.

(We're looking at formalizing this idea so the deployment tool will do it for you.)


I'm sure there are ways of redirecting URL's that will do the job as well, but I haven't tried it myself, I agree it doesn't look easy. Maybe someone else will comment on this thread.

Cheers,
Danny

BrendanB
Posts: 29
Joined: Tue Nov 24, 2015 10:29 am

Re: Vanity URLs on the IBM i

Post by BrendanB » Tue Jan 10, 2017 4:58 pm

To do this, you will need to create a webserver running on (eg. port 80), using the ibm web console.

Assuming you did that, modify the httpd.conf for this webserver to have:

this at the top

Code: Select all

# Load PROXY handling modules
#
LoadModule proxy_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
LoadModule proxy_http_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
LoadModule proxy_connect_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
LoadModule proxy_ftp_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
LoadModule proxy_balancer_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
and something like this at the bottom:

Code: Select all

<Location /ourapp/>
   ProxyPreserveHost Off
   Header set Access-Control-Allow-Origin "*"
   ProxyPass          "http://ourserver.com:4580/dcxpgmlib/sys/mobwebapp.html"
   ProxyPassReverse   "http://ourserver.com:4580/dcxpgmlib/sys/mobwebapp.html"
   ServerUserID DCXPGMLIB
</Location>
<Location /dcxpgmlib>
  ProxyPreserveHost Off
  Header set Access-Control-Allow-Origin "*"
  ProxyPass           "http://ourserver.com:4580/dcxpgmlib"
  ProxyPassReverse    "http://ourserver.com:4580/dcxpgmlib"
  ServerUserID DCXPGMLIB
</Location>
This should allow you to browse to http://ourserver.com/ourapp/ and end up with your app showing (without changing the location in the browser).

You may need to adjust image locations if they are loaded from '/images' (although a rule could be added for that...)

jyoung
Posts: 653
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: Vanity URLs on the IBM i

Post by jyoung » Fri Jan 13, 2017 2:19 am

We ended up with a client side redirect solution. Not super happy with it but it works (sort of, more later).

Since we a have a web server on the iSeries running on port 80, I dropped an ourapp.html file at the root. Inside the html is a meta refresh to the correct url.

It works great with pretty much every thing, except Android, although not, Android's, LANSA's or the iSeries fault. The reason it does not work and one the core reasons for trying to do this as that we have to access the app through VMWare's AirWatch Browser. Frankly, I don't have anything good to say about that browser. For some reason, the Android version of that browser blocks websites with long urls, although it works fine in iOS. Our IT guy is trying to figure it out, but is not having much success.

Which is the whole reason for the silent url rewrite. :D Would like to get the URL rewrite solution working at some point but have to move on to other things now.

Thanks Danny and Brendan for the info.

HamadSheikh
Posts: 27
Joined: Fri Mar 18, 2016 3:49 am
Location: USA
Contact:

Re: Vanity URLs on the IBM i

Post by HamadSheikh » Fri Jan 13, 2017 2:56 am

Perhaps you can take a look at tinyurl too:

http://tinyurl.com/

Does the job quite simply.

Post Reply