Win a flower (🌹) or copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java (📚) this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
master stewards:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
garden masters:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
gardeners:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Design Pattern for Proxy Redirects with Multiple Websites Pulling in Data from a Central Website?

 
pioneer
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just in the process of thinking through a design pattern for a specific feature and wanted to bounce a few ideas off other people who may have implemented this before.

Requirements;

https:// www.main-website.com/api/ is to power all of the functionality in the background. Java based web application
http:// something.another-website.com is to pull in content from www.main-website.com/api/something.another-website.com/
something.another-website.com may or may not be https, as such, nothing more than basic information will be being served which is publicly accessible anyway
My thoughts on this currently are;

http:// something.another-website.com, use .htaccess (or equivalent for Nginx / IIS) to set up a proxy redirect along the lines of;

RewriteEngine on RewriteRule "^(.*)$" "https:// www.main-website.com/api/something.another-website.com" [P] ProxyPassReverse "/" "https:// www.main-website.com/api/"

Ref: https:// httpd.apache.org/docs/2.4/rewrite/proxy.html

This way, whenever someone accesses http:// something.another-website.com, then this is passed over to https:// www.main-website.com/api/something.another-website.com to handle and serve the content, all while appearing to the user that they are still on the http:// something.another-website.com website at all times.

The concept being that many websites will be using the API to pull in basic content into their own website which is all managed through a central platform at https:// www.main-website.com/.

A few questions on the topic;

Does this sound like a solid design pattern?
Are there likely to be any challenges related to a http website proxying through to a https website to request content?
Is there anything else I should be thinking about?

This framework is going to be the basis of a larger API as things scale, so I'm trying to foresee any challenges and make sure this is designed as best as possible from the start.

Regards, Michael
 
master steward
Posts: 15026
251
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, first let's get some terminology straight. A design pattern is just that, a pattern. That means that there are at least a few known implementations that follow the pattern. The rule of thumb is that you need three different instances to be able to say there's a pattern. A pattern is not a recipe. Rather it is a general description. There can be numerous instances of where a pattern is followed and it's possible for each instance to be different from each other in some ways.
 
Michael Cropper
pioneer
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, with this in mind. It's more of a way of achieving the end result. Does the above outline sound like a good plan, are there any better options with these requirements?


Regards,
Michael
 
Junilu Lacar
master steward
Posts: 15026
251
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Michael Cropper wrote:
This framework is going to be the basis of a larger API as things scale, so I'm trying to foresee any challenges and make sure this is designed as best as possible from the start.


I've been in this business long enough to confidently say that programmers are not able to see into the future. Otherwise, it would be a very different world we'd be in right now. The best way that I know of to prepare for the future is not by trying to guess what it's going to be but to arrange your code so that you can easily adapt it when the future arrives. This requires simple (see Four Rules of Simple Design) and well-factored code (see Clean Code and Refactoring)

Michael Cropper wrote:
Requirements ...


Are what you gave "requirements" or are they your idea for a "solution"? There's a difference. Inferring from other things you wrote, I'm inclined to think these are not requirements.

As far as the approach you are describing, I don't fully understand what you're trying to do but it seems like I would hesitate to do that if it were me. Just the idea of redirecting user requests from one website to another seems fishy to me and it could lead to users mistrusting the URLs involved. It's hard to put a proper context of the problem when all you give are pseudo site names and no hint as to what you're ultimately trying to achieve. Again, what you gave seem like implementation details of a specific solution you have in mind, not implementation-agnostic requirements. The only context I can really relate to what you described is a security-related one and all my spidey senses start to tingle when I read your "requirements" in that context.
 
Michael Cropper
pioneer
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Had a test of a few different options with this, wasn't possible using mod_proxy as planned. iFrame was also a no-go as was changing DNS settings on a sub-domain, both due usability issues when navigating and requesting resources etc. So had to build a RESTful JSON API with a couple of lines of code that could be included on the 3rd party websites which then pulled in all the content with jQuery and pushed the data into the DOM. Still in progress, but results looking very positive so far.
 
Junilu Lacar
master steward
Posts: 15026
251
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good to hear that your initial "requirements" turned out not to be such and that you've found another workable solution. Seems like the RESTful API would be simpler to implement and understand, too.
 
This tiny ad is suggesting that maybe she should go play in traffic.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!