1

I am trying to configure a reverse proxy to my backend server.

This is my previous configuration which is working.

Define REMOTE_ADDR proxyserver.domain.com

<VirtualHost *:443>
    ProxyRequests Off
    KeepAlive On
    ProxyPreserveHost Off

    RewriteEngine On

    RewriteCond %{HTTP:Upgrade} =websocket
    RewriteRule /prefix/(.*) wss://${REMOTE_ADDR}/prefix/$1 [P,L]
    RewriteCond %{HTTP:Upgrade} !=websocket
    RewriteRule /prefix/(.*) https://${REMOTE_ADDR}/prefix/$1 [P,L]

    ProxyPass / https://${REMOTE_ADDR}/prefix/ connectiontimeout=5 timeout=300
    ProxyPassReverse / https://${REMOTE_ADDR}/prefix/ 
</VirtualHost>

This is my new configuration.

I want to redirect to:- proxyserver.domain.com/prefix/sen/app/9d12ponf12-2awf2-wafa/sheet/219uaw9dw-waf2/state/analysis

Note: The Remote address will always be the same. I have given an example but this is what it looks like in real as well.

I haven't included SSL information as that is not relevant to my problem.

Define REMOTE_ADDR proxyserver.domain.com

<VirtualHost *:443>
    ProxyRequests Off
    KeepAlive On
    ProxyPreserveHost Off

    RewriteEngine On

    RewriteCond %{HTTP:Upgrade} =websocket
    RewriteRule /prefix/sen/app/9d12ponf12-2awf2-wafa/sheet/219uaw9dw-waf2/state/analysis(.*) wss://${REMOTE_ADDR}/prefix/sen/app/9d12ponf12-2awf2-wafa/sheet/219uaw9dw-waf2/state/analysis$1 [P,L]
    RewriteCond %{HTTP:Upgrade} !=websocket
    RewriteRule /prefix/sen/app/9d12ponf12-2awf2-wafa/sheet/219uaw9dw-waf2/state/analysis(.*) https://${REMOTE_ADDR}/prefix/sen/app/9d12ponf12-2awf2-wafa/sheet/219uaw9dw-waf2/state/analysis$1 [P,L]

    ProxyPass / https://${REMOTE_ADDR}/prefix/sen/app/9d12ponf12-2awf2-wafa/sheet/219uaw9dw-waf2/state/analysis connectiontimeout=5 timeout=300

    ProxyPassReverse / https://${REMOTE_ADDR}/prefix/sen/app/9d12ponf12-2awf2-wafa/sheet/219uaw9dw-waf2/state/analysis
</VirtualHost>

It gives 'Too many redirects error'.

I am now stuck and can't figure how to setup rules for a URL like my REMOTE_ADDR.

Any help is appreciated.

Edit- Provided my previous working configuration and also updated my current configuration to show the relation between them.

I've written /analysis$1 and not /analysis/$1 because when I try to access my server directly, some dynamic strings are appended to it, for e.g. /analysis?example

Renegade
  • 11
  • 2
  • 1
    Configure your backend server properly. It's most probably responsible for the additional redirects. – Gerald Schneider Dec 29 '21 at 11:59
  • 3
    Try adding a forward slash / to the `ProxyPass.` directive to ensure they slashes are balanced i.e. `ProxyPass / https://${REMOTE_ADDR}/` – Bob Dec 29 '21 at 12:21
  • I updated the question with more information. Added my previous working configuration and also updated my current one to show where I am currently at. – Renegade Dec 29 '21 at 13:19
  • "I've written `/analysis$1` and not `/analysis/$1` because ..., some dynamic strings are appended to it, for e.g. `/analysis?example`" - `$1` would not contain `?example`, but the query string would be appended by default anyway. – MrWhite Dec 29 '21 at 17:46

0 Answers0