0

We've 2 instances of an app (prod and nonprod) running on a server. Other than the ports there is no difference in the uri for both. Prod: http://myserver:4444/myapp NonProd: http://myserver:5555/myapp

I've configured apache reverse proxy to access these apps over https instead of http. Below config works fine but just for nonprod instance.

<VirtualHost *:443>
    ServerName myserver
    DocumentRoot /var/www/test
    SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/selfsigned.crt
    SSLCertificateKeyFile /etc/pki/tls/private/selfsigned.key

    RewriteEngine on
    ProxyPreserveHost On

    SSLProxyEngine on
    ProxyPassMatch "/myapp(.*)"  "http://myserver:4444/myapp$1"
    ProxyPassReverse "/myapp(.*)"  "http://myserver:4444/myapp$1"

</VirtualHost>

What's the best way to add another app instance ? I've tried defining another virtualhost but that doesn't work. I added

Listen 8443 https
<VirtualHost *:8443>
    ServerName myserver
    DocumentRoot /var/www/test
    SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/selfsigned.crt
    SSLCertificateKeyFile /etc/pki/tls/private/selfsigned.key

    RewriteEngine on
    ProxyPreserveHost On

    SSLProxyEngine on
    ProxyPassMatch "/myapp(.*)"  "http://myserver:5555/myapp$1"
    ProxyPassReverse "/myapp(.*)"  "http://myserver:5555/myapp$1"

</VirtualHost>

when accessed https://myserver:8443/myapp the url automatically redirects to htto and give Bad Request suggesting I used http where https was expected. When I change the url again to https it then redirects to http://myserver:8080/myapp which gived Bad url as no backend is running on 8080.

I also tried putting Prefix but that doesn't work as well. Gives Bad url error.

ProxyPassMatch "/nonprod/myapp(.*)"  "http://myserver:5555/myapp$1"
ProxyPassReverse "/nonprod/myapp(.*)"  "http://myserver:5555/myapp$1"

ProxyPassMatch "/prod/myapp(.*)"  "http://myserver:4444/myapp$1"
ProxyPassReverse "/prod/myapp(.*)"  "http://myserver:4444/myapp$1"

Any help appreciated. Thanks

Abhishek
  • 45
  • 1
  • 6

0 Answers0