I have a Django project behind a ProxyPass server in Apache.
The project has an app called 'home', with this url patterns: urls.py
urlpatterns = [
path('', views.HomeView.as_view(), name='index'),
path('projects', views.HomeView.as_view(), name='dashboard'),
path('projects/<int:pid>/members',
views.ProjectMembersView.as_view(), name='project.members'),
There are two URL that have the same View class (the first used for the root).
In the HomeView class uses a template called 'dashboard.html' and get a list of projects to send to the template view
class HomeView(LoginRequiredMixin, ListView):
template_name = 'home/dashboard.html'
context_object_name = 'projects'
login_url = 'accounts.login'
def get_queryset(self):
... # returns a list of projects
The template renders a tablet with some information of the project and an URL to see the employess working on the project template
<td class="align-middle text-center text-sm">
<a href="{% url 'project.members' pid=project.id %}">See employees</a>
</td>
In the case, the project behind the Apache ProxyServer, the URL generated in the template is the form: "https://example.com/4554/members", here, Django doesn't recognizes the URL
The other situation, without Apache Proxypass the URL generated is like this: "http://127.0.0.1:8000/projects/4554/members", Django can recognize the URL and return the template when click in the link.
The ProxyPass configuration in Apache is in file: "/etc/apache2/sites-enabled/the-projects.conf" proxypass
<VirtualHost *:80>
ServerName example.com
ErrorLog /var/log/apache2/projects_perror.log
CustomLog /var/log/apache2/projects_access.log combined
RequestHeader set X-Forwarded-Proto 'https' env=HTTPS
ProxyPass /projects http://127.0.0.1:8000
ProxyPassReverse /projects http://127.0.0.1:8000
Alias /static/ /home/me/developer/projects/static/
<Directory "/home/me/developer/projects/static/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
What am I missing to render the right URL in the template when using Apache ProxyPass