I have partially developed a property website that fetch properties data from a RETS IDX. You may know that RETS server listened to port 6103 over http protocol. My website is deployed on a shared hosting due to which I can not connect to 6103 port. I do have a dedicated server (which allows connect to port 6103). I want to use this dedicated server as a middle tier between my website and the RETS IDX server. My problem is I want to develop that middle tier script i.e HTTP Tunnel.
My website will send all RETS request to this Tunnel that will meanwhile sent it to the RETS IDX server and its response will be sent back to the website at the same moment.
port 80 port 6103
Website (shared hosting) ----------> Tunnel (Dedicated hosting) -----------> RETS Server
RETS Server also requires to login, so the session should be maintained properly.
I want to have quick/best solution to do the job. May be through .htaccess or streaming php script or may be some third party script can also cut some of my time.
I would love to hear any thought or suggestion you have.
P.S: I can not move my website to a dedicated server because in near future I am going to have plenty of them and they would cost too much.
I'd personally go for the Reverse Proxy approach. This will allow you to intelligently forward requests, based on configurable criteria.
Both Apache and nginx have reverse proxy capabilities (in fact it was nginx's original purpose). For Apache you need to use
mod_proxy
, while nginx has the functionality built in unless you explicitly disable it before compiling.Of these two options I personally prefer nginx, it is robust and lightweight, and completely fit for purpose. I find Apache more cumbersome, but if you already have Apache set up on your dedicated server, you may prefer to use that instead.
The beauty of using web servers to proxy, is that they understand the underlying protocol. They will preserve headers, modify cookies (preserve sessions), and translate hostnames correctly.
Apache Config
In both cases configuration is very straightforward, the Apache config looks something like the following:
There's also options for tweaking cookies, setting timeouts etc. All of which can be found in the mod_proxy documentation
You should note that this cannot go in a
.htaccess
file. It must go in the main server config.nginx Config
Equally as simple
Again tons of options in the HttpProxyModule documentation for caching, rewriting urls, adding headers etc.
Please do consult the docs. I've not tested either of these configurations and they may be a little off as they're from memory + a quick google.
Make sure you test your app by proxying to an unreachable server and ensure it handles failures correctly since you are introducing another point of failure.
I'm working on the assumption you are able to configure your own dedicated server. If this is not the case, your hosts may be willing to help you out. If not leave me a comment and I'll try and come up with a more robust curl option.