Web Development – Best Way to Protect Website Application Code

htmlserverurlweb-applicationsweb-development

Background

I have a web application that I host on my own server. I have clients who use the application as is, but some have asked if they can host the application on their own server. This enables them to have their own URLS rather than mine. The application only forms part of their website so I'm assuming it will not be possible for my server to respond to a direct call to their domain etc

To give some examples, i currently have urls like www.mydomain.com/profile, www.mydomain.com/index.php?option=someoption&view=someview&id=1 What my clients' want is www.theirdomian.com/profile, www.theirdomian.com/index.php?option=someoption&view=someview&id=1 etc

Question

My question is, what is the best way for me to allow them to use their own URLs with my application, without giving them all the backend source code and databases to install on their server?

One way I thought would be to create a router.php file that sits on their server. The router then asks my server to output the html. When a link is clicked on the clients site, the router receives the request and forwards the request to get the data from my server etc.

Is this an effective way to achieve what I want, or is it way off the mark.

Best Answer

There are a few technical solutions to this:

  • Have them point their domain to your server, and configure your server to accept such requests; this is a simple DNS change, but it does mean that their entire domain now runs on your server.
  • Have them set up a reverse proxy on their end that rewrites the desired requests to your domain. Apache, for example, has modules for this (see https://httpd.apache.org/docs/2.2/mod/mod_proxy.html), including filters to rewrite URLs inside the documents you serve; this is kind of a hassle to set up, and it doesn't work for everything, but it may be worth giving a shot - if it does work, your application will run transparently under their domain, served through their servers, but running on your own servers. The basic idea is that their server matches request URLs against a certain pattern, forwards them to your server, and then changes the URLs in the response it receives before sending it back to the client. (Basically, this is your router.php solution, only at the web server level, thus with less hassle.)
  • Have them put an iframe into their page, in which they just put your page. If the iframe has 100% width and height, the user won't see the difference (except that navigation does not change the visible URL). This is by far the easiest solution.
  • Split up your application into a service layer and a front end. Deliver the front end, but keep the service layer on your server. This way, they can only make use of your service through your server; the front-end without the service layer is relatively useless.
  • Install and maintain a server (physical or virtual) on their network that runs your application; set it up so that they cannot access it (strong passwords, full-disk crypto, etc.).

However, the problem is a social one, not a technical one, and the proper social solution is to set up a proper contract (hint: you do need a lawyer for this) that clearly states what they can and cannot do with it, and deliver the code. Yes, you need to trust them not to violate the contract in clever ways; but that's just the way of the world.

If you absolutely cannot trust them not to be criminals, then maybe you should just decline the offer and make your money elsewhere.

Related Topic