skip to Main Content

I would like to configure HTTPD as a reverse proxy to redirect only the call for URL with the hostname only (for example: https://site1.com/), and then leave other call with specific directives.
Please see below some of the proxy.conf configuration as an example:

<VirtualHost *:443>
ServerName site1.com

ErrorLog /var/log/httpd/site1.com-443-error_log
TransferLog /var/log/httpd/site1.com-443-access_log

...

<Location /wsdata>

    ProxyPass https://site1.com/
    ProxyPassReverse https://site1.com/

    RewriteEngine on
    RewriteCond %{HTTP:UPGRADE} websocket [NC]
    RewriteCond %{HTTP:CONNECTION} upgrade [NC]
    RewriteRule .*  "wss://site1.com%{REQUEST_URI}" [P]

<Location /run>
    ProxyPass               https://site1.com/run/
    ProxyPassReverse        https://site1.com/run/?app_name=App1&page_name=Page1/
</Location>

ProxyPass               /        https://site1.com/
ProxyPassReverse        /        https://site1.com/run/?app_name=App1&page_name=Page1/

</VirtualHost>

I appreciate any help to get this configured.

2

Answers


  1. Chosen as BEST ANSWER

    I had to change that directive a little bit. To check if the URL requested is the "root" (/): RewriteCond %{REQUEST_URI} ^/$

    And then the Redirection rule, to include the code 301 for a permanent redirection:

    RewriteRule ^ site1/run/?app_name=App1&page_name=Page1 [R=301,L]

    And now it is working fine.


  2. Your question is pretty vague … I understand that you are looking for a way to proxy only requests to the empty path (/), but let alone requests to other paths.

    You can use the rewriting module for this. It is able to use the proxy module in background:

    RewriteEngine on
    RewriteRule ^/?$ https://%{HTTP_HOST}/run/?app_name=App1&page_name=Page1/ [P,L]
    

    The only trick is to use a matching pattern that only matches the empty path: ^/?$

    That pattern will work likewise in the http server’s host configuration or inside a distributed configuration file (".htaccess").

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search