Skip to main content

Proxy - Apache

Ref: Apache Module mod_proxy

Enable proxy module

a2enmod proxy
a2enmod proxy_http

Proxy request to backend server

ProxyPass "/" "http://<server>/"

Proxy request that is start with /api/

  • Request /api/get will get proxy to http://<server>/get
ProxyPass "/api/" "http://<server>/"

Modify the Location response header from the backend server to proxy server

  • Most often required
ProxyPass "/" "http://<server>/"
ProxyPassReverse "/" "http://<server>/"

ProxyPass to a HTTPS server

SSLProxyEngine on

# Check if the host from request URI match the CN of the server certificate
SSLProxyCheckPeerName { on | off }

# Checked if the remote server certificate is expired
SSLProxyCheckPeerExpire { on | off }

ProxyPass "/" "https://<server>/"
ProxyPassReverse "/" "https://<server>/"

ProxyPass in <VirtualHost>

<VirtualHost *:80>
ServerName host.example.com
ProxyPass ...
</VirtualHost>

If no SSLEngine on, Apache get this error

Oops, no RSA or DSA server certificate found for ...