We need NGINX to be able to serve our site with any possible subdomain. Edit the config/nginx.conf file and replace this line:
server_name www.educaproject.com educaproject.com;
With the following one:
server_name *.educaproject.com educaproject.com;
By using the asterisk, this rule applies to all subdomains of educaproject.com. In order to test our middleware locally, we need to add any subdomains we want to test to /etc/hosts. For testing the middleware with a Course object with the slug django, add the following line to your /etc/hosts file:
127.0.0.1 django.educaproject.com
Then open https://django.educaproject.com/ in your browser. The middleware will find the course by the subdomain and redirect your browser to https://educaproject.com/course/django/.