Nginx Proxy GuardNginx Proxy Guard

Redirect Hosts

NginxProxyGuard's redirect host feature allows you to easily configure traffic redirection between domains.

Overview

Redirect hosts forward incoming requests to a different URL. Unlike proxy hosts, they don't forward traffic to a backend server but instead tell the client to navigate to a new URL.

Common Use Cases

1. Force HTTP → HTTPS Redirect

http://example.com → https://example.com

Convert all HTTP traffic to HTTPS for security.

2. WWW Subdomain Consolidation

http://www.example.com → https://example.com
https://www.example.com → https://example.com

Unify www/non-www for SEO and consistency.

3. Domain Migration

https://old-domain.com/* → https://new-domain.com/*

Forward traffic when moving from an old domain to a new one.

4. Path Redirect

https://example.com/old-page → https://example.com/new-page

Connect old URLs to new URLs when restructuring sites.

Supported Status Codes

Status CodeTypeDescriptionCaching
301PermanentSearch engines index new URLBrowser cached
302TemporarySearch engines keep original URLNot cached
307Temporary RedirectPreserves HTTP method (POST → POST)Not cached
308Permanent RedirectPreserves HTTP method + permanentBrowser cached

When to Use Which Code?

  • 301: Domain changes, www consolidation, permanent changes
  • 302: A/B testing, temporary maintenance pages
  • 307: Temporary redirects that must preserve POST requests
  • 308: Permanent redirects that must preserve POST requests

Configuration

Basic Setup

  1. Navigate to Redirects menu
  2. Click Add Redirect Host button
  3. Enter the following:
    • Source Domain: The original domain to redirect
    • Target URL: The redirect destination URL
    • Status Code: Select from 301, 302, 307, 308
    • Preserve Path: Whether to append original path to target URL

Preserve Path Option

With Preserve Path enabled:

https://old.com/blog/post-1 → https://new.com/blog/post-1
https://old.com/about → https://new.com/about

With Preserve Path disabled:

https://old.com/blog/post-1 → https://new.com/
https://old.com/about → https://new.com/

Wildcard Support

Redirect hosts support wildcard domains:

*.example.com → https://example.com

Redirects all subdomains (blog.example.com, api.example.com, etc.) to the main domain.

SSL Certificate Integration

Redirect hosts also need SSL certificates for HTTPS:

  1. Issue certificate for source domain in Certificates menu
  2. Select the certificate in redirect host settings
  3. Enable automatic HTTP → HTTPS redirect

Differences from Proxy Hosts

FeatureProxy HostRedirect Host
Traffic HandlingProxy to backendClient redirect
ResponseBackend response3xx status code
Content ModificationPossibleNot possible
Security FeaturesWAF, bot filter, etc.Basic SSL only
Use CaseServing applicationsURL transitions

Best Practices

SEO Recommendations

  1. Use 301/308 for permanent changes

    • Allows search engines to index new URL
  2. Avoid redirect chains

    • Set A → C directly instead of A → B → C
  3. Utilize path preservation

    • Enable preserve path when site structure is identical

Performance Optimization

  1. Remove unnecessary redirects

    • Redirects cause additional requests
  2. Leverage caching

    • 301/308 are cached by browsers, reducing repeat requests

Troubleshooting

Infinite Redirect Loop

  • Check if source and target are the same domain
  • Verify no conflict between proxy host and redirect host

Redirect Not Working

  • Verify DNS settings are correct
  • Check SSL certificate is valid
  • Perform nginx config sync (Sync to Nginx)

POST Requests Converting to GET

  • Use 307 or 308 status codes
  • 301/302 may convert POST to GET
Nginx Proxy Guard - Modern & Secure Nginx Proxy Manager