Apache2.4 RewriteRule como proxy para servidor Apache2.2 remoto

Apache2.4 RewriteRule como proxy para servidor Apache2.2 remoto

Temos um aplicativo legado com URL https://www2.devDocApp.com/ que está rodando Ubuntu8e apache2.2sem suporte a TLS 1.2, tivemos dificuldades para atualizar apache2.2e openSSL na caixa Ubuntu 8, então agora estamos em apacheum servidor proxy ( devapp01Windows 2012 VM com Apache/2.4.29 (Win64) ) que redireciona todas as solicitações parahttps://www2.devDocApp.com/

Abaixo está a configuração do Apache que usei para configurar o servidor proxydevapp01

<VirtualHost *:443>
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload" 
DocumentRoot "C:/apache/htdocs"
ServerName  devapp01    
#ErrorLog "|bin/rotatelogs.exe -l -f C:/apache/logs/apache_error_log.%m-%d-%y-%I-%M-%S.log 86400"
#TransferLog "|bin/rotatelogs.exe -l -f C:/apache/logs/apache_transfer_log.%m-%d-%y-%I-%M-%S.log 86400"

SSLEngine on

#SSLProtocol -ALL +TLSv1 +TLSv1.1 +TLSv1.2 
#SSLHonorCipherOrder on
#SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"
#SSLCompression off

SSLProtocol -ALL TLSv1.2
SSLCertificateFile "C:/apache/conf/server.cer"
SSLCertificateKeyFile "C:/apache/conf/server.key"
#SSLCertificateChainFile "C:/apache/conf/server-ca.cer"
SSLCACertificateFile "C:/apache/conf/ca.cer"
SSLVerifyClient optional
SSLVerifyDepth  3

<FilesMatch "\.(cgi|shtml|phtml|php)$">
    SSLOptions +StdEnvVars
</FilesMatch>
<Directory "C:/apache/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

#CustomLog "|bin/rotatelogs.exe C:/apache/logs/ssl_request.%m-%d-%Y_%H_%M_%S.log 86400" \
#          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
#ProxyPass should be prior to any other Proxy directives
ProxyPass   /DocApp https://www2.devDocApp.com/ 
SSLProxyEngine on

RewriteEngine On        
RewriteRule  ^/DocApp$  https://www2.devDocApp.com/  [R,L]  

RequestHeader set X_SSL_CLIENT_M_SERIAL "%{SSL_CLIENT_M_SERIAL}s"
RequestHeader set X_FORWARDED_PROTO "https" env=HTTPS
RequestHeader set SslSubject "%{SSL_CLIENT_S_DN}s"

</VirtualHost>

Quando estou acessando o URL do proxy Apache https://devapp01/DocApp/para o qual ele está redirecionando https://www2.devDocApp.com/no navegador, como faço para que funcione de forma que o URL no navegador seja sempre https://devapp01/DocApp/<Page>para todos os caminhos aninhados, como https://devapp01/DocApp/page1 https://devapp01/DocApp/page2/page1em vez de redirecionar para https://www2.devDocApp.com/page1e https://www2.devDocApp.com/page2etc.?

Responder1

Isso faz o redirecionamento:

RewriteEngine On        
RewriteRule  ^/DocApp$  https://www2.devDocApp.com/  [R,L]  

Remova. O ProxyPassjá faz o truque.

Responder2

você deveria tentar proxy desta forma

RewriteEngine  on
RewriteRule    "^DocApp/(.*)$"  "https://www2.devDocApp.com/DocApp/$1"  [P]
ProxyPassReverse "/DocApp/" "http://www2.devDocApp.com/DocApp/"

adicionamos uma diretiva ProxyPassReverse para garantir que quaisquer redirecionamentos emitidos pelo backend sejam repassados ​​corretamente ao cliente.

melhores informações aqui: https://httpd.apache.org/docs/2.4/rewrite/proxy.html

informação relacionada