I have Apache, Django, and MySql images set up in my Docker container. Below is my docker-compose.yml file ...
version: '3'
services:
mysql:
restart: always
image: mysql:5.7
environment:
MYSQL_DATABASE: 'maps_data'
# So you don't have to use root, but you can if you like
MYSQL_USER: 'chicommons'
# You can use whatever password you like
MYSQL_PASSWORD: 'password'
# Password for root access
MYSQL_ROOT_PASSWORD: 'password'
ports:
- "3406:3306"
volumes:
- my-db:/var/lib/mysql
command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
web:
restart: always
build: ./web
ports: # to access the container from outside
- "8000:8000"
env_file: .env
environment:
DEBUG: 'true'
command: /usr/local/bin/gunicorn maps.wsgi:application --reload -w 2 -b :8000
volumes:
- ./web/:/app
depends_on:
- mysql
apache:
restart: always
build: ./apache/
ports:
- "9090:80"
#volumes:
# - web-static:/www/static
links:
- web:web
volumes:
my-db:
Within my Apache configuration, I have set up this virtual host to route traffic to my Django instance ...
<VirtualHost *:80>
ServerName maps.example.com
ProxyPreserveHost On
ProxyPass / http://web:8000/
ProxyPassReverse / http://web:8000/
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"
</VirtualHost>
My question is, how do I alter the above configuration to only send traffic to my Django instance in which the URL begins with the words "data" or "coops"?
you can try apache rewrite engine :
RewriteEngine on
RewriteCond %{REQUEST_URI} data
RewriteRule ^/(.*)$ http://doamin or webapp/$1 [L,R=301]