Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a client-side-rendered Angular production build, configure Nginx to serve the build output over HTTPS, route Angular pages back to index.html, and return security headers that match the application. Treat the configuration below as a starting point: output paths, subpath deployments, TLS support, header inheritance, and CSP requirements all depend on your Nginx installation and app.

What this Nginx layer does—and does not do

This guide covers Nginx serving Angular’s static production files. Angular says client-side-rendered apps are suitable for static hosting because their content is generated at build time. Nginx can provide the HTTPS endpoint, serve assets, direct client-side routes to the app shell, and add response headers. It does not replace application-level authentication, authorization, or security review.

If the application uses Angular server-side rendering (SSR), requests may need to reach an application server rather than be served solely as static files. The configuration here is for the static-serving case, not a complete SSR reverse-proxy setup.

Build the app and identify its actual output path

Create a production build and deploy the configured output directory. Angular’s CLI documentation describes dist/my-app/ as the default output location, but the builder’s outputPath can change it. Point Nginx’s root at the directory that actually contains the built index.html and assets; do not assume the default path applies to your project. See Angular’s deployment guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

For deployment below a path such as /portal/, check the generated <base href> and asset URLs as well as Nginx’s filesystem mapping. Angular generally prefers <base href> where possible; --deploy-url is fixed into the build at build time, so it is less flexible if the deployment URL changes.

Make Angular routes load without hiding missing files

Angular handles many routes in the browser. A visitor opening a route directly or refreshing it sends that path to Nginx first, so the server needs to serve index.html for URLs intended for Angular. Nginx’s try_files checks candidates in order and can internally redirect to its final URI when none exists.

server {
    listen 443 ssl;
    server_name example.com;

    root /var/www/angular-app/browser;
    index index.html;

    location / {
        try_files $uri $uri/ /index.html;
    }
}

This is a pattern, not a drop-in complete server configuration. Replace the example hostname and root with your deployment values, and integrate it with the TLS and header configuration you use. The example’s catch-all fallback can return the app shell for an unknown URL—including a missing asset path—rather than a genuine 404. That can conceal deployment mistakes and give clients a misleading success response.

Choose fallback behavior for the actual output

  • Client-side routes: Confirm a deep link and a browser refresh load the Angular app.
  • Assets: Ensure nonexistent JavaScript, CSS, image, and font files produce the intended error, not the app shell. Depending on your file layout and URL conventions, handle asset paths separately from application routes.
  • Prerendered pages: If the build contains route-specific HTML, map those generated files deliberately rather than assuming every route should use one shell.
  • Subpath deployments: Align the Nginx location and root or alias behavior with the deployed path and the build’s base URL.

Nginx documents the ordered checks and internal-redirection behavior of try_files. The correct location ordering and fallback depend on the app’s output structure and URL strategy.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Enable HTTPS and protect the private key

Nginx’s HTTPS configuration uses an SSL-enabled listener and certificate paths. A simplified example is:

server {
    listen 443 ssl;
    server_name example.com;

    ssl_certificate     /etc/ssl/certs/example-chain.pem;
    ssl_certificate_key /etc/ssl/private/example-key.pem;

    root /var/www/angular-app/browser;
    index index.html;

    location / {
        try_files $uri $uri/ /index.html;
    }
}

Use paths and certificate files provisioned for your host; the example is not a certificate-management procedure. The certificate is public, but the private key is sensitive. Restrict access while ensuring the Nginx master process can read it. Certificate-chain order matters, and an incorrectly assembled chain can prevent Nginx from starting. Nginx’s HTTPS guide documents these directives and certificate considerations.

The Nginx HTTPS guide shows TLS 1.2 and TLS 1.3 and describes them as defaults in that context, but directive defaults have changed over time. Verify protocol support and effective configuration for your installed Nginx build, OpenSSL version, and distribution rather than assuming every server has the same defaults. Avoid copying cipher settings without checking those details and your organization’s requirements.

For source builds, the SSL module is not built by default and requires OpenSSL to build and run. Packaged installations differ, so verify that the installed Nginx has the necessary module support. See the Nginx SSL module documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Add response headers with inheritance and error paths in mind

Nginx’s add_header behavior depends on both response status and configuration level. Without always, it applies only to the documented set of response codes; adding always makes the header independent of status. Under the standard inheritance model, a parent-level set of add_header directives is inherited only when the current level has none of its own. A nested location that adds one header can therefore change whether it receives the parent set.

The current Nginx documentation also describes add_header_inherit, introduced in Nginx 1.29.3. Do not assume that directive is available on older installations. Check the documentation for the version actually deployed. See Nginx’s add_header documentation.

There is no universal header list established for every Angular app. Choose headers through an application-specific review, then verify their presence on each relevant response path. In particular, review:

  • The application document at / and a client-side route
  • JavaScript, CSS, image, and other static assets
  • A missing asset and other not-found responses
  • Error responses and any location blocks that define their own headers

Placing headers at a shared server level may help coverage, but location-level directives and status-code rules can change the result. Verify what the deployed server actually emits rather than inferring coverage from one configuration block.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Set CSP to fit Angular’s runtime behavior

Angular’s guidance is direct: “To enable CSP, configure your web server to return an appropriate Content-Security-Policy HTTP header.” A policy that works for one app may block another. Build the policy from the app’s actual scripts, styles, API calls, images, fonts, analytics, identity providers, and other external origins, then validate it before enforcing it broadly.

Angular documents this minimal policy for a new app:

default-src 'self'; style-src 'self' 'nonce-randomNonceGoesHere'; script-src 'self' 'nonce-randomNonceGoesHere';

The example’s nonce text is illustrative, not a value to copy as-is. When using nonces, generate a unique, unpredictable value per response and make the same value available to the Angular document, such as through the ngCspNonce root attribute or the CSP_NONCE injection token. If a CDN caches HTML containing one origin-generated nonce and serves it to many visitors, the nonce is no longer unique per response. Angular describes generating a nonce at the edge just before delivery as one option for that deployment shape.

Choose a nonce approach that fits caching

Approach When it fits Trade-offs to account for
Per-response nonce The serving layer can generate a fresh unpredictable nonce and deliver it consistently in the CSP header and Angular document. Requires coordination between response generation and the HTML. Caching must not reuse the same nonce across visitors; an edge-generated nonce just before delivery is one documented option.
Static HTML without a per-response nonce The host serves index.html unchanged and cannot inject a fresh nonce into each response. Angular documents disabling critical CSS inlining and leaving subresource integrity disabled as alternatives. Disabling critical CSS inlining can slow initial rendering, and disabling subresource integrity removes script integrity checks. Runtime component styles still need consideration; Angular’s no-per-response-nonce example allows 'unsafe-inline' in style-src.
App-specific directives and origins The application loads resources or connects to services beyond its own origin. Identify the actual origins and resource types used by the app. A policy that omits a required origin can break functionality; allowing unnecessary sources weakens the policy.

These approaches are not interchangeable security guarantees. In particular, do not hard-code a static nonce in HTML that is served unchanged. Angular’s security guide explains nonce delivery, critical CSS, subresource integrity, and policy configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Check Trusted Types requirements

Angular recommends considering Trusted Types as another XSS defense. Policy names depend on framework features, so enable only the policies the application needs and test the built app:

  • angular is required for Angular internals.
  • angular#bundler is relevant to CLI-generated lazy chunks.
  • angular#unsafe-bypass is needed if the app uses DomSanitizer bypass APIs.
  • angular#unsafe-jit applies when using JIT compilation.
  • angular#unsafe-upgrade applies to AngularJS hybrid applications.

Enforcing a policy without checking which features the app uses can break behavior. Test the policy against lazy-loaded routes and the app’s actual runtime paths, not just its initial page.

Keep Nginx virtual-host routing distinct from Angular SSR host checks

Nginx selects a name-based virtual server using the request’s Host. If no configured server name matches, or the host is absent, the request goes to the default server for that port; the default can be set explicitly. Review this behavior so an unexpected hostname does not serve the Angular site accidentally. See Nginx’s server names documentation.

That Nginx routing is separate from host validation in Angular SSR. Angular’s SSR engine has allowed-host and trusted-proxy-header controls. Trust forwarded headers only when a trusted proxy strictly validates or overrides them; a client-controlled forwarded header should not be treated as authoritative. This guide’s static Nginx setup does not configure those SSR controls.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Test configuration and behavior in the deployed environment

nginx -t checks configuration syntax and referenced files, but it cannot establish that routes, TLS negotiation, browser CSP behavior, or emitted headers work as intended. After applying changes, validate both the configuration and actual responses:

  1. Confirm the build: Check the production output directory, outputPath, base URL, and deployed asset paths.
  2. Test Nginx configuration: Run nginx -t with the same installation and configuration that will serve traffic. See Nginx command-line switches.
  3. Exercise route handling: Open the root page, directly load a client-side route, and refresh it. Request a nonexistent asset and confirm it returns the intended error rather than the app shell.
  4. Check HTTPS: Inspect the certificate, chain, negotiated protocol, and private-key file permissions on the actual deployment.
  5. Inspect response headers: Check successful document and asset responses as well as missing-file and error responses. Include nested locations that define their own add_header directives.
  6. Validate CSP and Trusted Types: Exercise inline styles or scripts, runtime component styles, lazy chunks, and all required external origins. Confirm the Trusted Types policies match features the app actually uses before enforcement.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.