Apache VirtualHost Generator

Generate an Apache VirtualHost with a proxy pass and HTTPS redirect in your browser.

  • Runs locally in your browser
  • No upload required

Try it

File
apache-vhost.conf
Blocks
VirtualHost
Content
# Generated in the browser — review this file and adapt it to your project before committing. <VirtualHost *:80> ServerName example.com DocumentRoot /var/www/example RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] ProxyPreserveHost On ProxyPass / http://backend:3000/ ProxyPassReverse / http://backend:3000/ </VirtualHost>
# Generated in the browser — review this file and adapt it to your project before committing.
<VirtualHost *:80>
  ServerName example.com
  DocumentRoot /var/www/example

  RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  ProxyPreserveHost On
  ProxyPass / http://backend:3000/
  ProxyPassReverse / http://backend:3000/
</VirtualHost>

Supported formats

Input
text
Output
text

Privacy

Runs entirely in your browser. Your input is never uploaded, stored, or sent to a third party.

Processing
In your browser
Privacy level
Browser only

Generated an Apache VirtualHost for example.com with 15 line(s).

How it works

  • Wrote the VirtualHost opening line and server identity.
  • Set the document root and proxy pass directives.
  • Added the mod_rewrite HTTP→HTTPS redirect.
  • The proxy directives require mod_proxy and mod_proxy_http; the redirect requires mod_rewrite.
  • Run `apachectl configtest` yourself before reloading Apache.

Methodology

  1. Validate the server name, optional admin email, document root and upstream.
  2. Emit the VirtualHost with ServerName, DocumentRoot and proxy directives.
  3. Prepend the mod_rewrite redirect only when requested.

Usage

  1. Enter the server name, document root and proxy upstream.
  2. Optionally add an admin email and enable the HTTPS redirect.
  3. Copy the block into your Apache site configuration.

Examples

These are examples, not current values: they use fixed inputs, while the interactive tool computes live results in your browser.

Reverse proxy with HTTPS redirect

jsonSelect to copy
{
  "serverName": "example.com",
  "serverAdmin": "admin@example.com",
  "documentRoot": "/var/www/example",
  "upstream": "http://backend:3000",
  "redirectHttp": true
}

Limitations

What the generated block assumes

The VirtualHost listens on `*:80`, sets `ServerName` and `DocumentRoot`, forwards to the upstream with `ProxyPass`/`ProxyPassReverse`, and adds a rewrite rule when the redirect is enabled.

Frequently asked questions

Why are there no SSL directives?
The generated block listens on port 80 and redirects to HTTPS; a TLS listener belongs in a separate `<VirtualHost *:443>` with your certificate paths.
Does ProxyPass need a trailing slash?
Yes; the generator appends one so `/` maps to the upstream root.

Sources

  1. Apache VirtualHost examples — Apache Software Foundation
  2. mod_proxy documentation — Apache Software Foundation