User documentation
  1. What is redirection.io?
  2. Starter's guide
  3. What are organizations and projects?
  4. Invite new collaborators
  5. User account and preferences
  6. Using traffic logs
  7. Create a rule
  8. Triggers and markers reference
  9. Actions reference
  10. How to bulk-import or export redirection rules?
  11. Managing instances
  12. Project notifications
  13. Project segmentation
  14. How much does it cost?
  15. Can I use redirection.io for free?
  16. About us

Developer documentation
  1. TL;DR; Fast track
  2. Available integrations
  3. nginx module
  4. Apache module
  5. platform.sh integration
  6. Cloudflare Workers integration
  7. Fastly Compute@Edge integration
  8. Vercel Middleware Integration
  9. Using redirection.io with Docker
  10. How fast is it?
  11. Public API

Agent documentation
  1. Installing the agent
  2. Upgrading the agent
  3. Agent command line options
  4. The agent as a reverse proxy
  5. Agent configuration reference
  6. Minimal configuration
  7. Listening for requests
  8. Forwarding requests to the backend
  9. Virtualhosts
  10. Trusted proxies
  11. GeoIP database
  12. Response compression
  13. Performance tweaks
  14. Access logs
  15. Persisting data in a s3 bucket
  16. Monitoring the agent
  17. Using the agent behind a HTTPS proxy
  18. Agent configuration examples

Managed instances
  1. What are managed instances?
  2. Add a domain to your project
  3. Managed instances limits and quota
  4. Frequently asked questions

Crawler
  1. What is the redirection.io crawler?
  2. Start a crawl
  3. Schedule a crawl
  4. Analyzing the results of a crawl
  5. The crawls list
  6. Crawl credits and pricing
  7. Crawl Errors
  8. Crawler metrics reference
  9. Crawler columns reference

Knowledge base
  1. Create your first redirections
  2. redirection.io rules cookbook
  3. Setting up a redirection server on Azure Cloud
  4. Structured data and Rich Snippets
  5. What is a URL redirection?
  6. Why use URL redirections and how to setup

Legacy versions
  1. Agent 1.x configuration reference
  2. Agent 2.x configuration reference
  3. Legacy integrations
  4. Legacy Cloudflare Workers integration

Changelogs
  1. redirectionio-agent
  2. libnginx-mod-redirectionio
  3. libapache2-mod-redirectionio

Virtualhosts

In the redirection.io agent, Virtualhosts allow to define a configuration for a specific set of domains. This is useful if you want to host multiple websites on the same agent without the need to bind each website to a specific port. The agent will automatically route the requests to the correct backend based on the requested domain, using the Host header of the request.

The virtualhosts configuration is defined under the virtual_hosts key in the agent configuration. Each virtualhost is defined by a list of domains that it should handle, and it allows to specify all the configuration options that usually live under the reverse_proxy key, such as the forward, certificate or trusted_proxies configuration, etc. Here is a configuration example for multiple virtualhosts:

View in configuration explorer
instance:
    name: 'My Instance'
reverse_proxy:
    listen:
        - 'tcp://0.0.0.0:80'
        - 'tls://0.0.0.0:443'
    forward:
        address: '127.0.0.1:8080'
    agent:
        project_key: DEFAULT_PROJECT_KEY
    certificate:
        acme:
            contacts:
                - myemail@example.com
            directory_url: 'https://acme-v02.api.letsencrypt.org/directory'
    virtual_hosts:
        -
            domains:
                - example.com
                - www.example.com
            agent:
                project_key: WEBSITE_PROJECT_KEY
        -
            domains:
                - 'tls://media.example.com'
            forward:
                directory: /var/www/media
            agent:
                project_key: MEDIA_PROJECT_KEY

The configuration defines two Virtualhosts, one for the example.com and www.example.com domains, and one for the media.example.com domain. Each virtualhost has its own configuration, with different redirection.io project keys.

With such a reverse proxy configuration:

  • the agent will accept all incoming connections on ports 80 and 443
  • by default, the requests will be handled using the DEFAULT_PROJECT_KEY redirection.io project and forwarded to the backend at 127.0.0.1:8080 in http
  • requests to example.com and www.example.com will use the the redirection.io project that has the project key WEBSITE_PROJECT_KEY, and will be forwarded to the default forward address (127.0.0.1:8080), in http
  • requests received on media.example.com in tls will be sent to a filesystem backend, and associated with the redirection.io project that has the project key MEDIA_PROJECT_KEY

If two Virtualhost configurations overleap, the agent will use the first one that matches the requested domain. For example, if you have a Virtualhost configuration for example.com, and another one for both example.com and www.example.com, then a request made to example.com will use the first VirtualHost, because it is defined first in the configuration file. To avoid this issue, make sure to define your Virtualhost configurations in the correct order, with the most specific ones defined first.

This page has been updated on Mar 30, 2026
Can't find your answer?