Forum Moderators: phranque

Message Too Old, No Replies

Is this possible?

         

khuram

2:01 pm on Feb 24, 2010 (gmt 0)

10+ Year Member



Hi,

I have a problem where I have to copy the data to another website. However, I am thinking that I only copy the database and not copy images and if a user requests an image from that site then apache will redirect the request to our original site.
e.g.
on www.example.com website, if I do
<a href="/images/someimage.gif" />

Then apache, should make it like.

<a href="http://www.mothersite.com/images/someimage.gif" />

But this process should be internal without the user realizing that the images are being served from another website. Is this possible? Please help.

Regards,

jdMorgan

2:24 pm on Feb 24, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's possible if you have the privileges required to configure a reverse proxy on the front-end (database) server and to configure custom logging on the back-end (image) server. The image server will then serve as a back-end to the server holding the database.

There are some side effects, though. First, each client request for an image will result in a second request being sent from the front-end server to the back-end server, and the front-end server will then have to wait for the back-end server to send it the image data, which it will then have to send to the client. So, bandwidth on the front-end server will double.

The back-end (image) server's logs will show all requests as originating at the front-end server, unless the front-end server is set up to send the HTTP X-Forwarded-For header to the back-end server, and the back-end server is configured to log that header instead of logging the usual REMOTE_ADDR(ess) or REMOTE_HOST.

Because each client request to the front-end now results in a second HTTP request from the front-end to the back-end, image-loading performance will be twice as slow.

In addition, if either server (or its DNS, or its internet connection, or its power, or its cooling system) fails, image-loading will fail. Reliability is therefore only 50% (on average) of what it was before.

Setting this up should be possible as long as you have administrator rights on the servers. If not, upgrade to VPS or dedicated-server service levels. Then check out the Apache mod_proxy documentation at apache.org.

Jim

khuram

2:35 pm on Feb 24, 2010 (gmt 0)

10+ Year Member



Hi Jim,

But I do not require a database for this. I just need to images in a certain folder to be loaded from another website. I am sure this shouldnt be this difficult. I can imagine about the double http request but shouldnt it be a simple RewriteCond ?

jdMorgan

3:50 pm on Feb 24, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For your stated requirements of "Don't show the other server's URL," it *is* this difficult, or really I wouldn't have bothered to type all that...

Otherwise if you do show the other server's URL, then it's a simple 301 or 302 redirect.

Jim

khuram

4:37 pm on Feb 24, 2010 (gmt 0)

10+ Year Member



Hi Jim

Thanks for the kind help mate. I have used php's ftp lib to copy all images to new website as per need. Thanks all the same.

Have a nice day!