Background
We have an application using React.js for the frontend and Django for the backend. We are attempting to deploy this application on an Azure virtual machine with IIS.
Problems Encountered
-
Backend Accessibility:
- We are uncertain whether our Django server is running and how to access it. Accessing
localhost
only serves the frontend, raising concerns about frontend-backend communication.
- We are uncertain whether our Django server is running and how to access it. Accessing
-
404 Error on Page Refresh:
- When navigating to
authentication/sign-in
from the frontend, it works fine. However, refreshing this page results in aHTTP Error 404.0 - Not Found
error. - It seems IIS is looking for a physical path that doesn’t exist, as the build folder contains only static files (CSS, JS, etc.).
- When navigating to
Steps Taken
- Created a new instance on Azure: Installed Python and other necessary packages.
- Configured IIS:
- Enabled IIS features and other relevant features.
- Installed SSL certificate (.pfx) using MMC to enable HTTPS support.
- Moved project folder to
C:inetpubwwwroot
. - Configured the Python path and FastCGI path in the
web.config
file, placed next to the project folder.
- Setup Virtual Directory:
- Moved the build folder (static build from React) to the virtual directory.
- Completed all configurations for mapping, FastCGI, and static file handling.
- Running the Application:
- The frontend is served successfully when accessed via
localhost
.
- The frontend is served successfully when accessed via
Resources Referenced
- YouTube Video on IIS Deployment
- Toptal Guide on Installing Django on IIS
- Nonstopio Blog on Deploying Django on IIS
Request for Help
- How can I confirm that the Django backend is running and determine the correct URL to access it?
- How can I configure IIS to correctly handle frontend routes (like
authentication/sign-in
) without resulting in a 404 error on refresh? (both are linked – not a different question)
Any insights or solutions would be greatly appreciated. Thank you!