Bitnami developer here!
At the end of the day, you have an Apache server listening for incoming connections on two ports (80 and 443) and you want to forward some of them to another backend server depending on the URI.
As you pointed out, this can be achieved with ProxyPass
and the proxy features built-in Apache. You can check out the original documentation for further reference.
https://httpd.apache.org/docs/2.4/mod/mod_proxy.html
Bitnami's LAMP separates each Apache VirtualHost
(80 and 443) config in two files, bitnami.conf
and bitnami-ssl.conf
. If you only want your users to access the API through SSL, you'll only need to modify bitnami-ssl.conf
. Additionally, I suppose you want to stick to the same SSL certificate your main domain is using, so you should skip the SSLProxyEngine
directive.
As an alternative to your proposed changes, you can append the following to the bitnami-ssl.conf
VirtualHost to proxypass some request depending on the sub-URI.
<VirtualHost _default_:443>
...
<Location "/example">
ProxyPass "http://example.com/"
ProxyPassReverse "http://example.com/"
</Location>
..
</VirtualHost>
After performing the changes, you need to make sure to restart Apache:
$ sudo /opt/bitnami/ctlscript.sh restart apache
You can check that the output is the same when using the proxypass and directly querying the upstream:
$ curl -k --silent https://34.XXX.XXX.XXX/example -o out.html && curl --silent https://example.com -o out2.html && diff <(md5sum out.html | awk '{ print $1 }') <(md5sum out2.html | awk '{ print $1 }')
Regards,
Jose Antonio Carmona