1

I am configuring a new virtual host on my apache reverse proxy with rewrite mod, when testing the configuration all working fine but only one page (image page) is not working. when clicking on image page I get the local URL in the browser ( https://localserver:9251/share/collab?collabSession=ea4a80bf-6c19-473b-ad08-bdce391dbe19&type=join&user=username&isInitiator=true).

the ports 9251, 433 and 80 are activated in ports.conf

there below my virtual hosts configuration:

<VirtualHost *:80>
    ServerName publicdomaine.com
    ServerAlias www.publicdomaine.com
    Redirect Permanent / https://publicdomaine.com
</VirtualHost>

<VirtualHost *:443>
    ServerName publicdomaine.com
    ServerAlias www.publicdomaine.com

    <IfModule mod_proxy.c>
        SetEnv proxy-nokeepalive 1

        SetEnv proxy-initial-not-pooled 1
        ProxyRequests Off
        ProxyPreserveHost Off

        ProxyPass / https://localserver/
        ProxyPassReverse / https://localserver/
    </IfModule>

    SSLEngine on
    SSLProxyEngine On
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerExpire off
    SSLCertificateKeyFile /etc/apache2/cert/mykey.pem
    SSLCertificateFile /etc/apache2/cert/mycert.pem
    SSLCertificateChainFile /etc/apache2/cert/bundle.crt

    RewriteEngine On
    LogLevel alert rewrite:trace6

    RewriteCond %{QUERY_STRING} ^(.*)&studyUid=(.*)
    RewriteCond %{QUERY_STRING} ^host=publicdomaine.com(.*)$
    RewriteRule ^/ris/web/imageshare/startSession - [E=SUI_VAL:%1]

    RewriteRule /ris/web/imageshare/startSession https://localserver/ris/web/imageshare/startSession?host=cimcsp1.cimy.local%{ENV:SUI_VAL} [P,QSA,L]

    ErrorLog /var/log/signoff-error_log

    CustomLog /var/log/signoff-access_log combined
</VirtualHost>

<VirtualHost *:9251>
    SetEnv proxy-nokeepalive 1
    SetEnv proxy-initial-not-pooled 1
    ProxyRequests Off
    ProxyPreserveHost Off

    ProxyPass / https://localserver:9251/
    ProxyPassReverse / https://localserver:9251/
</VirtualHost>

I have observed the http exchange with fiddler. message exchange:

GET https://publichostname/ris/web/imageshare/startSession?host=publichostname&studyUid=1.3.51.0.1.1.10.233.24.237.333827.7779290494 HTTP/1.1

the reverse proxy rewrite the parameter host to localserver :

GET https://publichostname/ris/web/imageshare/startSession?host=localserver&studyUid=1.3.51.0.1.1.10.233.24.237.333827.7779290494 HTTP/1.1

and the response is JSON:

{"initiatorLink":"https://localserver:9251/share/collab?collabSession=74bea62c-474a-4ee5-9d74-e793fef66738&type=join&user=username&isInitiator=true","studyUid":"1.3.51.0.1.1.10.233.24.237.333827.7779290494","baseLink":"https://localserver:9251/share/?collabSession=74bea62c-474a-4ee5-9d74-e793fef66738","closedLink":null}

this response tunnel me to :

CONNECT localserver:9251 HTTP/1.1
Host: localserver:9251

this should be tunnel me with the reverse proxy to:

CONNECT publichostname:9251 HTTP/1.1
Host: publichostname:9251
  • This maybe due to you trying to exemplify your code, however, there appears to be inconsistencies with your code (or parts missing) that make it difficult to follow? You appear to be proxying to localserver, but how is this handled? What hostname(s) are attached to the <VirtualHost *:9251> section and how is this being used? – MrWhite Jun 6 at 20:45
  • yes you are right. I have tryed to add server name in the <VirtualHost *:9251> but the first call in this port is do with a local hostname and it's not possible to acheminate the response to the end user. also tryed to add this in the <VirtualHost *:443> : ProxyPass / localserver:9251 ProxyPassReverse / localserver:9251 but it's the same issue. – caghiles3 Jun 7 at 11:32
1

The best option would be to configure your application server to generate the correct URLs to be used with the proxy.

However, if you can't do that, you can use another Apache module, mod_proxy_html. This module provides the directive ProxyHTMLURLMap, which you can use to rewrite the response.

ProxyPass / https://localserver/
ProxyPassReverse / https://localserver/
SetOutputFilter proxy-html # make sure the output is filtered by proxy-html
ProxyHTMLURLMap https://localserver:9251/ https://publichostname:9251/
ProxyHTMLExtended On       # by default only HTML output is filtered

This should rewrite all occurences of the localserver URL in the answer with the publichostname URL.

Note that this puts additional load on the webserver, since it has to analyze and modify every answer instead of just passing it through. Configuring the application server properly would be a preferred method.

  • the web server is working fine in local network. but whe need to publish this web server in internet and to do this we use a reverse proxy. – caghiles3 Jun 7 at 13:26
  • I have tested with your suggestion and it's the same issue. – caghiles3 Jun 7 at 19:49
0

found it !!! I have added the substtute mod to modify the server response and it's work !!!!! commande added:

AddOutputFilterByType SUBSTITUTE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript application/json
Substitute "s|https:\/\/localserver:9251|https:\/\/publichostname:9251|ni"

thanks for your helps !!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.