0

Have been trying to get an apache proxy set up to serve all content in a sub directory from a new application server

If I use this rewrite rule it works and I get redirected to the new site

RewriteRule ^/blog/(.+)/$ "https://master-7rqtwti-i7feq5lebr6se.eu-2.platformsh.site/blog/$1" [R,L]

So I tried changing this to a proxy directive:

RewriteRule ^/blog/(.+)/$ "https://master-7rqtwti-i7feq5lebr6se.eu-2.platformsh.site/blog/$1" [P,L]
ProxyPassReverse "/blog/" "https://master-7rqtwti-i7feq5lebr6se.eu-2.platformsh.site/blog/"

Didn't work.
Decided to try setting it up as a proxypass in a location block:

<Location "/blog/">
  SSLProxyEngine on
  ProxyPreserveHost on
  ProxyPass "https://master-7rqtwti-i7feq5lebr6se.eu-2.platformsh.site/blog/"
  ProxyPassReverse  "https://master-7rqtwti-i7feq5lebr6se.eu-2.platformsh.site/blog/"
</Location>

Still didn't work

Took the directives out of the Location block and edited them to be:

  SSLProxyEngine on
  ProxyPreserveHost on
  ProxyPass "/blog/" "https://master-7rqtwti-i7feq5lebr6se.eu-2.platformsh.site/blog"
  ProxyPassReverse "/blog/" "https://master-7rqtwti-i7feq5lebr6se.eu-2.platformsh.site/blog"

still not working

Switched off the certificate verification (I trust the cert on the new application server) :

SSLProxyVerify none 
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off

So finally, requests are getting passed through to the other server but now I am seeing a 404 error returned by the application server because the server doesn't understand the original URL (https://www.mysite.co.uk/blog/)

No errors in the log files in either server?!?!

What do I need to change to get this working?

Output of apachectl -S:

VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server indigo-1.mysite.co.uk (/etc/httpd/conf.d/000-mysite.conf:27)
         port 80 namevhost indigo-1.mysite.co.uk (/etc/httpd/conf.d/000-mysite.conf:27)
         port 80 namevhost www.mysite.co.uk (/etc/httpd/conf.d/zzz-mysite.conf:59)
                 alias mysite.co.uk
                 alias cdn.mysite.co.uk
         port 80 namevhost pugpig.mysite.co.uk (/etc/httpd/conf.d/zzz-mysite.conf:73)
         port 80 namevhost www.mysite2.co.uk (/etc/httpd/conf.d/zzz-mysite.conf:87)
                 alias mysite2.co.uk
                 alias cdn.mysite2.co.uk
*:443                  is a NameVirtualHost
         default server indigo-1.mysite.co.uk (/etc/httpd/conf.d/000-mysite.conf:44)
         port 443 namevhost indigo-1.mysite.co.uk (/etc/httpd/conf.d/000-mysite.conf:44)
         port 443 namevhost indigo-1.mysite.co.uk (/etc/httpd/conf.d/ssl.conf:56)
         port 443 namevhost www.mysite.co.uk (/etc/httpd/conf.d/zzz-mysite.conf:63)
                 alias mysite.co.uk
                 alias cdn.mysite.co.uk
         port 443 namevhost pugpig.mysite.co.uk (/etc/httpd/conf.d/zzz-mysite.conf:77)
         port 443 namevhost www.mysite2.co.uk (/etc/httpd/conf.d/zzz-mysite.conf:91)
                 alias mysite2.co.uk
                 alias cdn.mysite2.co.uk
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex authdigest-opaque: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default 
Mutex mpm-accept: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: _RH_HAS_HTTPPROTOCOLOPTIONS
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48
Jameel
  • 79
  • 5

1 Answers1

0

I got this to work by removing the ProxyPreserveHost setting so my final config is:

  SSLProxyEngine on
  SSLProxyVerify none
  SSLProxyCheckPeerCN off
  SSLProxyCheckPeerName off
  SSLProxyCheckPeerExpire off
  ProxyPass "/blog" "https://master-7rqtwti-i7feq5lebr6se.eu-2.platformsh.site/blog" retry=1 acquire=3000 timeout=600 Keepalive=on
  ProxyPassReverse "/blog"  "https://master-7rqtwti-i7feq5lebr6se.eu-2.platformsh.site/blog"
  ProxyPass "/assets" "https://master-7rqtwti-i7feq5lebr6se.eu-2.platformsh.site/assets" retry=1 acquire=3000 timeout=600 Keepalive=on
  ProxyPassReverse "/assets" "https://master-7rqtwti-i7feq5lebr6se.eu-2.platformsh.site/assets"
Jameel
  • 79
  • 5