Apache HTTP Server can be configured in both a forward and reverse proxy (also known as gateway) mode.
forward proxy
An ordinary forward proxy is an intermediate server that sits between the client and the origin server. In order to get content from the origin server, the client sends a request to the proxy naming the origin server as the target. The proxy then requests the content from the origin server and returns it to the client. The client must be specially configured to use the forward proxy to access other sites.
A typical usage of a forward proxy is to provide Internet access to internal clients that are otherwise restricted by a firewall. The forward proxy can also use caching (as provided by mod_cache
) to reduce network usage.
The forward proxy is activated using the ProxyRequests
directive. Because forward proxies allow clients to access arbitrary sites through your server and to hide their true origin, it is essential that you secure your server so that only authorized clients can access the proxy before activating a forward proxy.
reverse proxy
A reverse proxy (or gateway), by contrast, appears to the client just like an ordinary web server. No special configuration on the client is necessary. The client makes ordinary requests for content in the namespace of the reverse proxy. The reverse proxy then decides where to send those requests and returns the content as if it were itself the origin.
A typical usage of a reverse proxy is to provide Internet users access to a server that is behind a firewall. Reverse proxies can also be used to balance load among several back-end servers or to provide caching for a slower back-end server. In addition, reverse proxies can be used simply to bring several servers into the same URL space.
A reverse proxy is activated using the ProxyPass
directive or the [P]
flag to the RewriteRule
directive. It is not necessary to turn ProxyRequests
on in order to configure a reverse proxy.
django application
I am running my gunicorn application on port 8090 using following command.
“`/opt/venv/bin/python3.6 /opt/venv/bin/gunicorn –config /etc/controlpanel/gunicorn/controlpanel.py –pid /var/run/controlpanel.pid controlpanel.wsgi:application“`
static files path is “`/opt/controlpanel/ui-ux/static/“`
apache config (/etc/apache2/sites-enabled/cp.conf)
- enable mod_proxy module in apache
<VirtualHost *:80> ServerName devcontrol.lintel.com ErrorLog /var/log/httpd/cp_error.log CustomLog /var/log/httpd/cp_access.log combined ProxyPreserveHost On ProxyPass /static ! ProxyPass / http://127.0.0.1:8090/ ProxyPassReverse / http://127.0.0.1:8090/ ProxyTimeout 300 Alias /static/ /opt/controlpanel/ui-ux/static/ <Directory "/opt/controlpanel/ui-ux/static/"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost>
after deploying on Apache you can use lets encrypt to install SSL certificates.