I have Django app that runs in docker container. I have a problem with serving static files with my Apache configuration.
STATIC_URL = "/static/"
and DEBUG = False
settings properties/var/www/my_app/static/
directory/var/www/my_app
has correct acccess rights for apache: drwxr-xr-x 3 www-data www-data 4,0K June 11 16:25 my_app
This is my apache config:
<VirtualHost 000.00.0.000:443>
ServerName my_app.com
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /etc/apache2/certs/cert.pem
SSLCertificateKeyFile /etc/apache2/certs/cert.key
SSLCACertificateFile /etc/apache2/certs/DigiCertCA.crt
CustomLog /var/log/apache2/my_app.log combined
ErrorLog /var/log/apache2/my_app.log
ProxyPass /static !
Alias /static/ /var/www/my_app/static/
<Directory /var/www/my_app/static/>
Require all granted
</Directory>
<Location />
ProxyPass http://localhost:6000/
ProxyPassReverse http://localhost:6000/
ProxyPreserveHost on
</Location>
</VirtualHost>
When I commented out:
<Location />
ProxyPass http://localhost:6000/
ProxyPassReverse http://localhost:6000/
ProxyPreserveHost on
</Location>
than my static files are served properly. So it looks like that there is some issue that the this part of the config takes precedence.
Could you help me please to resolve the issue?
You can tell your proxy to ignore a certain directory with the ProxyPass !
directive.
Here is a working example
Alias "/static/" "/home/intranet/intraBlog/static/"
<Directory "/home/intranet/intraBlog/static">
Require all granted
</Directory>
<Location "/">
ProxyPass http://127.0.0.1:8000/
ProxyPassReverse http://127.0.0.1:8000/
</Location>
<Location "/static">
ProxyPass !
</Location>