Skip to content

Commit

Permalink
Limit Apache proxying to specific env config
Browse files Browse the repository at this point in the history
This change limits when Apache will proxy pass to the application to when the CFGOV_APPLICATION_HOST env var is set.
  • Loading branch information
willbarton committed Dec 10, 2024
1 parent 44f4236 commit b1ed08e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
11 changes: 11 additions & 0 deletions cfgov/apache/conf.d/proxy.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file is only used when running Apache and the application
# containerized. This configures Apache to ProxyPass to the application
# container when CFGOV_APPLICATION_HOST is defined in the environment.
#
# TODO: Remove the RewriteCond and switch to a simple ProxyPass when the
# application is moved to Gunicorn.
ServerName https://www.consumerfinance.gov

RewriteCond expr "-n env('CFGOV_APPLICATION_HOST')"
RewriteRule ^/(.*)$ http://${CFGOV_APPLICATION_HOST}:8000/$1 [P,L]
ProxyPassReverse / http://${CFGOV_APPLICATION_HOST}:8000/
4 changes: 4 additions & 0 deletions cfgov/apache/conf.d/wsgi.conf.venv
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Our classic mod_wsgi deployment will move this file into place if we're
# expecting to use mod_wsgi.
# TODO: Remove when the application is containerized or moved to Gunicorn

ServerName https://www.consumerfinance.gov

LoadModule wsgi_module modules/mod_${SCL_PYTHON_VERSION}-wsgi.so
Expand Down
6 changes: 0 additions & 6 deletions cfgov/apache/conf/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ Include conf.modules.d/*.conf
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.

# Default these values to apache/apache if the APACHE_USER and APACHE_GROUP
# env vars are not provided.
# TODO: Remove when Apache is containerized
SetEnvIfExpr "-n env('APACHE_USER')" APACHE_USER=apache
SetEnvIfExpr "-n env('APACHE_GROUP')" APACHE_GROUP=apache
User ${APACHE_USER}
Group ${APACHE_GROUP}

Expand Down

0 comments on commit b1ed08e

Please sign in to comment.