0

I have been trying to handle all requests via a NodeJS, except those going to the /admin directory via mod_proxy, but with no success.

This is the configuration I came up with, but it is not working.

<VirtualHost *:80>
    ServerName domain.com
    DocumentRoot /home/sites/domain.com/

    RewriteEngine on
    ReWriteCond %{SERVER_PORT} !^443$
    RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>

<VirtualHost *:443>
    ServerName domain.com
    DocumentRoot /home/sites/domain.com/

    ProxyRequests on
    ProxyPassMatch ^/(.*)$ http://localhost:3000/
    ProxyPassMatch ^/admin/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/home/sites/domain.com/php/public/$1 timeout=600
    ProxyTimeout 600

    SSLEngine on
    SSLCertificateFile /home/keys/domain.com.crt
    SSLCertificateKeyFile /home/keys/domain.com.key
</VirtualHost>
Ivo Sabev
  • 177
  • 1
  • 1
  • 5
  • 1
    Try moving the second `ProxyPassMatch` above the first. – Craig Watson Mar 21 '17 at 09:29
  • @CraigWatson you should type that in a "Answer" because that's what happens. Most specific uri must go first when using proxypass, first is overriding second. Also `ProxyPassMatch ^/(.*)$ http://localhost:3000/`looks odd, are you sure you don't want to do `ProxyPass / http://localhost:3000/` ? – Daniel Ferradal Mar 21 '17 at 09:41

1 Answers1

2

When using ProxyPass directives, the ordering matters, so you should move your second directive above the first.

Also, as ezra-s mentioned in their comment, you only need to add the (.*) if you intend on passing that to the destination, this should work:

ProxyPassMatch ^/admin/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/home/sites/domain.com/php/public/$1 timeout=600
ProxyPassMatch / http://localhost:3000/
Craig Watson
  • 9,575
  • 3
  • 32
  • 47