0

0 Introduction

I'm trying to setup a server with a main website hosted on ports 80 and 443 (let's call it example.com) and a section on this website that serves umami analytics hosted on port 3000 (let's call it umami.example.com) using a reverse proxy. I'm using Django and Apache (with mod_wsgi as hinted from the django project) and I have to setup DNS using Cloudflare.

The main website works as intended, redirecting http traffic to https (more on that on the Apache section) and I'm tring to add this section under umami.example.com but every request ends up in a 404 error given by my main website.

Currently I'm trying to make the umami part work using a reverse proxy (as shown in the first section of the Apache Config)

####################################################################

1 DNS

DNS are configured using Cloudflare with 3 A records:

  • example.com -> server IP address
  • umami -> same server ip
  • www -> again same ip

and some MX and TXT ones.

####################################################################

2 Apache Config

<VirtualHost _default_:80>
    ServerAdmin admin@example.com
    ServerName umami.example.com

    ProxyPass "/" "http://127.0.0.1:3000/"
    ProxyPassReverse "/" "http://127.0.0.1:3000/"
</VirtualHost>


<VirtualHost *:80>
   ServerName example.com
   ServerAlias www.example.com
   Redirect permanent / https://example.com/
</VirtualHost>


<VirtualHost _default_:443>
    ServerAdmin admin@example.com
    ServerName example.com
    ServerAlias www.example.com


    Alias /static /mainfolder/static
    DocumentRoot /mainfolder/django-folder

    <Directory /mainfolder/django-folder/static>
        Require all granted
    </Directory>

    <Directory /mainfolder/django-folder/django-app>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess django-folder python-path=/mainfolder/django-folder python-home=/usr/local/env
    WSGIProcessGroup django-folder
    WSGIScriptAlias / /mainfolder/django-folder/django-app/wsgi.py


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

</VirtualHost>

####################################################################

3 What I've tried

  • Connecting directly to the IP address bypassing the DNS (port 80) makes no difference.

  • Connecting directly to the IP address bypassing the DNS (port 3000) works as intended.

EDITED HERE
before

  • Swapping places on the Apache Config makes no difference.

after

  • Swapping places on the Apache Config works like this:
    • When the reverse proxy comes first (the config is as posted) then connecting to the 80 port serves the analytics website.
    • When the redirect comes first (swapped) connecting to the 80 port redirects to the HTTPS website

END EDIT

  • Adding and removing ProxyPreserveHost makes no difference.
Tox46
  • 13
  • 5
  • To state the obvious - Apache httpd requires a restart after changing the configuration. For more web server debugging - check the logs and test from a new incognito browser window and from the commandline with `curl -vv http://umami.example.com/some-page.html` as described here: https://serverfault.com/q/1092950/37681 – HBruijn Aug 12 '22 at 12:08
  • Curl actually made me spot a difference when swapping places on the Apache Config. I updated the question according to that – Tox46 Aug 12 '22 at 14:17
  • That suggests there is a typo in the ServerName directive – HBruijn Aug 13 '22 at 05:44

0 Answers0