I have a problem with my Apache2 web server as reverse proxy server. The simplified server setup with my domain "example.com" looks like this:

server setup

If clients now go to the page https://example.com/guacamole, then the Apache2 web server should forward the requests to the Tomcat server ( This part works.

If clients go to https://example.com/mydjangoproject, then the Apache2 web server should forward requests to the web server using Gunicorn and the Django project ( However, this configuration works only partially. The page https://example.com/mydjangoproject shows the main page of the Django project, but when calling the admin page https://example.com/mydjangoproject/admin the django application gives the error that the page does not exist. It seems like the sub-URL "/mydjangoproject/" is removed when calling the admin page. What could that be?

This is my configuration:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin admin@example.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem

    JKMount /* ajp13_worker

    SSLProxyEngine on
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    ProxyPreserveHost On

    ProxyPass /static/ !
    ProxyPass /mydjangoproject
    ProxyPassReverse /mydjangoproject

Thanks for your help!

Edit: When i try to enter the admin-page via https://example.com/mydjangoproject/admin then this error occurs:

error screenshot

  • 1
    First thing that I'd look at is the proxypass directives. Since /mydjangoproject is proxying, then https://example.com/mydjangoproject/admin will return whatever it finds at Is the admin panel you're expecting being served from there?
    – Kefka
    Jul 29, 2019 at 13:49
  • Hi Kefka! Thanks for your reply. Normally there should be the admin-panel. I edited my post with the error.
    – Markus
    Jul 29, 2019 at 16:42

1 Answer 1


You'll likely need to alter your ProxyPass and ProxyPassReverse directives to get this to work.

You should try replacing these lines:

ProxyPass /static/ !
ProxyPass /mydjangoproject
ProxyPassReverse /mydjangoproject

With e.g.:

# "Convenience" URL
ProxyPass /mydjangoproject
ProxyPassReverse /mydjangoproject

# --- The lines below are what actually allow access to /admin ---

# Proxy /admin for login
ProxyPass /admin
ProxyPassReverse /admin

# Proxy /static for CSS, etc.
ProxyPass /static
ProxyPassReverse /static

You should then be able to use e.g. https://example.com/admin to access your Django /admin page and get the correct login dialog:

ex. Django Admin Login

Django Admin Login - Screenshot

When I try to enter the admin page via https://example.com/mydjangoproject/admin an error occurs.

You should be able to add the following lines (in addition to those recommended above) to get this to (kind of) work:

ProxyPass /mydjangoproject/admin
ProxyPassReverse /mydjangoproject/admin

Note that Django seems to redirect ex. https://example.com/mydjangoproject/admin to ex. https://example.com/admin automatically, which breaks things unless you already have ex. ProxyPass /admin as an existing entry (included above).

  • Thanks for your help! Now it works! Perfect :)
    – Markus
    Jul 30, 2019 at 11:31
  • You're welcome. Glad you got it working. =) Jul 30, 2019 at 18:24
  • @Anaksunaman, your solution is fine, I had the same problem, thanks! Now, there is an issue: I'm using netbox (which is an IPAM) that faces this same situation. Now, your workaround is somehow rigid if there are plenty of redirections to configure under apache with the several ProxyPass and ProxyPassReverse. Is there any solution that may do this for all the URLs? Aug 30, 2020 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.