How to install IMWS on Apache Reverse Proxy

Started by hro, June 14, 2017, 12:23:51 AM

Previous topic - Next topic

hro

Hello All,

Has anybody successfully installed IMWS on Apache using Reverse Proxy?
I have a working Apache web server running various website and like to add IMWS (on a separate box than the IMWS service). I am reading and reading but can't seem to find the relevant stuff to make this work.

Would be fantastic to publish the setup/configuration here if someone got it to work.

Many thanks. Hartmut

Mario

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

hro

Mario, you should be in bed by now  ;)

The attached file shows what I see in the browser.
- Apache webserver and IMWS are on different boxes.
- Apache Reverse proxy configuration is currently like this
    ProxyRequests off
   ProxyPass /imatchviewer/ http://192.168.100.10:8081/imatchviewer/
   ProxyHTMLURLMap http://192.168.100.10:8081/imatchviewer/ /imatchviewer/
   <Location /imatchviewer/>
        ProxyPassReverse /imatchviewer/
        ProxyHTMLEnable On
        ProxyHTMLURLMap   /imatchviewer/ /imatchviewer/
        RequestHeader unset Accept-Encoding
   </Location>
- I can successfully run the viewer on the local IMWS box
-  "imwsUrl": "http://192.168.100.10:8081", - This is the entry in config.json

Any hints, clues much appreciated.

hro

Maybe this provides some more clues.

Mario

It's a while since I dabbled with Apache Reverse proxies...and I'm not a Linux Admin, mind.

It's a two part process.

Assuming the site name is "ima-demo.com"

Create /etc/apache2/sites-enabled/ima-demo.com.conf  and add:

# This is for running IMatch WebViewer on this Linux box:

ServerAdmin webmaster@ima-demo.com
ServerName ima-demo.com
ServerAlias www.ima-demo.com
DocumentRoot /var/www/ima-demo.com/public_html

# and this is for the reverse proxy, to redirect the /imws URL to the Windows machine http://bigbox3:8081/

ProxyPreserveHost On
ProxyPass /imws http://bigbox3:8081/

# You can then specify linux-box/imws as the imwsUrl for IMatchWebViewer and route all IMatch WebViewer traffic through the Linux box to the Windows machine running IMWS.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

hro

Hi Mario,
I followed your suggestions, tried a number of Apache configuration options, came back to your suggestions, but didn't have much more luck.

Here is my current configuration:

ServerAdmin webmaster@localhost
ServerName pics.otting.info
DocumentRoot "/var/www/pics.otting.info/public_html"

<Directory "/var/www/pics.otting.info/public_html">
  allow from all
  Options None
  Require all granted
</Directory>

ProxyPreserveHost on
ProxyPass /imws http://192.168.100.10:8081/

The attached screenshot shows you what I get with this configuration.

I assume the URL has to be (in my case) http://pics.otting.info/imws/imatchviewer/
I tried others to, but none seem to work.

Any further suggestions ??

Cheers. Hartmut

hro

Update.
I can get the info screen, if this is any help. See attached.

Mario

You access IMWS via ...otting.imws/info

so the proxy seems to work. It forwards this request to your Windows machine, correct?

But IMatch WebViewer is trying to connect to a local IP address to find IMWS. This cannot be right.
Make sure you enter the correct URL in the "imwsUrl" option of the IMatch WebViewer config. This should also be ...otting.de/imws
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

hro

Quote from: Mario on June 15, 2017, 09:05:16 AM
You access IMWS via ...otting.imws/info

so the proxy seems to work. It forwards this request to your Windows machine, correct?

But IMatch WebViewer is trying to connect to a local IP address to find IMWS. This cannot be right.
Make sure you enter the correct URL in the "imwsUrl" option of the IMatch WebViewer config. This should also be ...otting.de/imws

Hmmh, not sure if I can follow you here.
- Yes, I access IMWS via "pics.otting.info/imws/..."
- Yes, WebViewer is trying to access to the IMWS service via local IP address.

- Apache Server is Internet facing and sits on 192.168.100.20
- IMWS W10 Server is not Internet facing and sits on 192.168.100.10
- Apache connects to the W10 server via the IP address (they are local on the same subnet)
- I have local DNS and I can access correctly locally and the services I have allowed from the Internet
- I can run WebViewer perfectly on the LAN by entering the above URL (or IP address of course)

Strange is that I by entereing the URL (from the Internet) pics.otting.info/imws/info I get the info screen.
By entering ..../imws/imatchviewer/ I get the initial ImatchViewer splash screen, but then a timeout (error message as previously submitted)

You say this configuration cannot be right. I don't see what would be configured incorrectly. Maybe I don't fully understand the IMWS configuration requirements.
The "imwsUrl" option of the IMatch WebViewer config needs to point to the IMWS service machine, correct?

Thanks.

Mario

QuoteThe "imwsUrl" option of the IMatch WebViewer config needs to point to the IMWS service machine, correct?

The proxy in your case.

192.168.* are local IP addresses, not accessible from the Internet.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

hro

Yes, but isn't that the point?
Only the Apache Server (Proxy Server) should be able to access the IMWS server on the LAN (192.168.100.10)
Internet users can only access the Apache Server, hiding the IMWS server.

Mario

Have you set the IMatchWebViewer config.json to use the public URL of your proxy?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

hro

Quote from: Mario on June 16, 2017, 12:41:38 AM
Have you set the IMatchWebViewer config.json to use the public URL of your proxy?

Yes, I did this now and it worked!

Many thanks Mario.

I guess I confused myself quite a bit, probably don't understand enough how IMWS and ProxyServer on Linux are working together and are to be configured. I didn't get that the imwsURL needs to point to the "external" URL. Not sure if that is clear enough in your documentation.

At the moment I have to enter as external URL "http://server.com/imws/imatchviewer/" and that works. However, I'd rather have "http://server.com" to get to the ImatchViewer. I tried many ProxyPass directive and imwsURL combinations, but I don't seem to be able to accomplish that.
Any ideas?

After that I will change it to SSL but think I'll have that under control.

Thanks. Hartmut



hro

Quote from: hro on June 19, 2017, 04:16:37 AM
However, I'd rather have "http://server.com" to get to the ImatchViewer. I tried many ProxyPass directive and imwsURL combinations, but I don't seem to be able to accomplish that.
Any ideas?

Ok, I think I have managed to solve this by adding a RewriteRule directive to the Apache configuration.
In case someone is interested:

RewriteEngine on
RewriteRule   ^/$  /imws/imatchviewer/  [R]

This seems to work beautiful. I hope I don't break anything else with this rule.


Mario

The imwsUrl tells IMatch WebViewer which IMWS server to use.

Since IMatch WebViewer runs in your browser and thus in the public network, it needs the public URL of IMWS: The Apache Proxy. Requests sent to the public proxy are forwarded to the hidden IMWS in your network, and the response from IMWS is forwarded by the proxy to the browser running IMatch WebViewer.

I don't see why you would need rewrite rules, though. Rewrite rules are used on a web server to internally translate URLs to other URLS.

Basically this proxy thing is really easy.

Tell Apache to forward all requests sent to /imws to another computer (the Windows machine running IMWS).

ProxyPreserveHost On
ProxyPass /imws http://YOUR-PC:8081/


is usually all that is needed.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

hro

Quote from: Mario on June 19, 2017, 09:54:44 AM
I don't see why you would need rewrite rules, though. Rewrite rules are used on a web server to internally translate URLs to other URLS.

Yes, I understand. The proxy rules work correctly.
However, I have to enter "http://server.com/imws/imatchviewer/", but what I really want is to enter is
"http://server.com" only.

The rewrite rules allowed me to do that and it appears to work.

Cheers. Hartmut

Mario

Year, for that you need a Rewrite rule. I don't recall you mentioning that.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook