logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: replace image on the fly
Author
dsfraser



Joined: 19 Aug 2016
Posts: 2
Location: USA, Seattle

PostPosted: Sat 20 Aug '16 3:53    Post subject: replace image on the fly Reply with quote

I have a setup that is using a video switcher that has an embedded web server and page for online control. I have managed to configure a Raspberry Pi (cheap and small) to be a reverse proxy to the switcher. So when you access the url of the Pi from outside it will serve the web page from the video switcher living on the private network, and allow you change the video feed. I should probably also mention I'm using the localhost tunneling program PageKite.

It all works rather well, and given my "I really don't know what I doing status" I was very pleased. Of course now they want to implement 2 or 3 more of these setups to remote locations.

The web page from the switcher is embedded in firmware and cannot be changed. So if I have 3 switches I would have 3 identical pages. It has the possibility to get confusing for the operators.

So what I would like to do is to brand the individual switches somehow, Site #1, Site #2 something to give the user a clue as to which one they are dealing with.

Is it possible to have the apache server on the Pi insert or replace an image, on the fly, when it serves the video switchers web page? There is a large 'top_bar.gif' on each page with the manufacturers name, and there is plenty of room to add text to it. So hopefully I could have a copy on the Pi and whenever it passed the switchers page it would substitute the changed 'top_bar.gif'.

I've been playing around with mod_rewrite but the best I've managed to do is block the embedded gif's from loading, it never seems to find the replacement ones on the Pi.

Some of the different things I've tried

RewriteEngine On
RewriteRule /images/(.*)\.gif$ /home/pi/$1\.gif

RewriteCond %{REQUEST_URI} images\top_bar.gif
RewriteRule .* /home/pi/top_bar.gif [L]

RewriteRule /images/top_bar.gif /home/pi/top_bar.gif

Anyway, I'm thankful for any pointers.
Back to top
mraddi



Joined: 27 Jun 2016
Posts: 152
Location: Schömberg, Baden-Württemberg, Germany

PostPosted: Tue 23 Aug '16 23:47    Post subject: replace image on the fly Reply with quote

I've created a directory "prx" within the apache's document-root and within this "prx"-directory a file ".htaccess" (maybe you need "AllowOverride All" within apache's "<Directory>"-section to allow this to work).

The .htaccess-file looks like this:
Code:
RewriteEngine on
RewriteRule "images/(.*\.gif)" "/images/$1" [L]

RewriteRule "^(.*)"  "http://192.168.0.4/$1" [P,L]


This rewrites every request for a gif-file within /prx/images/ to the /images/-directory of the local webserver and proxies the rest within the /prx/-directory to the backend-webserver 192.168.0.4

Maybe this helps a little for your problem Question
Back to top
dsfraser



Joined: 19 Aug 2016
Posts: 2
Location: USA, Seattle

PostPosted: Wed 24 Aug '16 4:32    Post subject: Reply with quote

Thank-you very much!

With your pointers and help I was able to accomplish what I needed to do... it only took a week of banging my head on the desk, and in the end so simple.

I really only had to replace one gif so I was able to pare it down to:

RewriteEngine on
# LogLevel alert rewrite:trace3
RewriteRule "images/top_bar.gif" "/my_top_bar.gif" [L]

I guess the trick was placing my_top_bar.gif in the /var/www/html/ directory not in the user home, where it never seemed to get found.

Thanks again
dsfraser
Back to top


Reply to topic   Topic: replace image on the fly View previous topic :: View next topic
Post new topic   Forum Index -> Apache