Deploying an Angular application to a Windows server using IIS (Internet Information Services) is a common scenario in enterprise environments. This tutorial walks you through every step of the process: from building your Angular app to handling routing via IIS URL Rewrite rules.
π§° Prerequisites
Before you begin, ensure:
- You have an Angular application ready (
Angular CLIinstalled). - Your Angular app builds correctly with
ng build. - IIS is installed on your Windows server.
- Optional: Admin rights on the server.
ποΈ Step 1: Build the Angular App for Production
Start by generating a production-ready version of your Angular project.
π§ Build Command
ng build --configuration production
β οΈ If you’re using Angular v12+, you can also use:
ng build --prod
This will generate a dist/ folder with your compiled project. The folder path will look like:
dist/your-project-name/
Inside this folder, you’ll find:
index.htmlmain.*.js,runtime.*.js,polyfills.*.js, etc.- Your assets
π Step 2: Install IIS on Windows (If Not Already Installed)
π How to Install IIS:
- Go to Control Panel β Programs and Features
- Click Turn Windows features on or off
- Check Internet Information Services
- Press OK and wait for installation to complete
π Step 3: Add a New Website in IIS
- Open IIS Manager
- In the Connections pane, right-click Sites > Add Website
- Configure the website:
- Site Name:
MyAngularApp - Physical path: Browse to
dist/your-project-name - Port: e.g.,
80or8080 - Hostname (optional):
my-angular.local
- Site Name:
Click OK to create the site.
π§± Step 4: Configure MIME Types (Optional but Recommended)
Angular serves .js, .css, .json, .woff2, etc. Make sure IIS can serve them:
- In IIS Manager, go to your site β MIME Types
- Add missing types like:
.jsonβapplication/json.woff2βfont/woff2
π Step 5: Install and Configure URL Rewrite for Angular Routing
Angular uses HTML5 pushState routing, so deep links like /about or /dashboard must route back to index.html.
π§© Install URL Rewrite Module
- Go to Microsoftβs official URL Rewrite download page
- Install it on your IIS server
π Add Rewrite Rule
In IIS Manager:
- Select your Angular site
- Double-click URL Rewrite
- Click Add Rulesβ¦ > Choose Inbound Rules β Blank Rule
- Set rule name:
AngularRoutes - Match URL:
- Requested URL:
Matches the Pattern - Using:
Regular Expressions - Pattern:
^(?!.*\.(js|css|png|jpg|jpeg|gif|ico|json|svg|woff2|woff|ttf|eot|map)$).*$
- Requested URL:
- Conditions:
- Add:
{REQUEST_FILENAME} - Check if “Is File” β
False - Add another:
{REQUEST_FILENAME}β “Is Directory” βFalse
- Add:
- Action:
- Action type:
Rewrite - Rewrite URL:
/index.html
- Action type:
This tells IIS to serve index.html for all non-file, non-folder routes β allowing Angular to handle routing.
π Step 6: Set Folder Permissions
Make sure the IIS application pool user (typically IIS_IUSRS) can read the contents of the dist/ directory.
Steps:
- Right-click your
dist/your-project-namefolder β Properties - Go to the Security tab
- Click Edit, add
IIS_IUSRSwith Read & Execute permissions
β Step 7: Restart and Browse Your Angular App
- In IIS Manager, right-click your new site β Manage Website β Restart
- Open a browser and navigate to:
http://localhost/or
http://your-domain.com/
Your Angular application should now load correctly β and handle client-side routing without 404 errors.
π§ͺ Optional Step: Enable HTTPS
To serve your app over HTTPS:
- Obtain an SSL certificate (e.g., via Let’s Encrypt, or a self-signed cert)
- Bind the HTTPS port in IIS:
- Go to your site β Bindings β Add β Select
httpsand choose the certificate
- Go to your site β Bindings β Add β Select
π οΈ Common Issues and Fixes
| Issue | Fix |
|---|---|
| 404 errors on refresh | URL Rewrite rule missing |
MIME type error (e.g., .json not loading) | Add MIME types in IIS |
| Styling or JS not applied | Base href misconfigured; ensure <base href="/"> in index.html |
| Access denied | Check folder permissions for IIS_IUSRS |
| App loads but routes donβt work | URL Rewrite not redirecting to index.html |
π§ Final Thoughts
Hosting an Angular app on IIS is simple and efficient once your production build and routing are correctly configured. IIS serves static files well and, with URL Rewrite, you get seamless Angular routing support.


