How to Configure OPAC and Staff Domains for Koha with Name-Based Virtual Hosts
Overview
Our custom Koha Amazon Machine Images (AMIs), available through the AWS Marketplace, allow you to use your own custom domain (for example, library.yourdomain.com) for both the OPAC and staff interfaces. Using a personal domain makes your library system more professional, easier to remember, and easier for patrons to access.
This guide provides two options:
- Method A: Configure the domain during the initial AWS Marketplace launch using the CloudFormation template.
- Method B: Configure or change the domain later using the Koha command-line tool.
Both methods require DNS (Domain Name System) configuration. DNS maps human-readable names (like library.yourdomain.com) to your server’s IP address using A records.
1. Before You Begin
You will need:
- A registered domain name (Cloudflare, Namecheap, Route 53, GoDaddy, etc.)
- Access to your DNS provider’s dashboard
- A Koha AMI deployment launched through the AWS Marketplace
- The relevant CloudFormation parameters, depending on the method you choose
Method A: Custom Domain Setup During Launch (CloudFormation Template)
This method configures your custom domain while you launch Koha using the AWS Marketplace “Launch with CloudFormation” option.
A1. Locate Your CloudFormation Stack
When you subscribe and launch Koha from the AWS Marketplace, AWS automatically creates a CloudFormation stack.
- Log in to the AWS Console
- Open CloudFormation
- Look under Stacks for a stack name beginning with
Koha-AMI-or the name you entered during setup
A2. Find the Elastic IP (EIP)
The EIP is required to configure DNS.
- Open your CloudFormation stack
- Click the Resources tab
- Search for a resource of type AWS::EC2::EIP
- The “Physical ID” value is your server’s public IP
A3. Create DNS A Records
In your DNS provider, create two A records pointing to the Elastic IP.
| Hostname | Example | Target |
|---|---|---|
| OPAC site | library.yourdomain.com |
Elastic IP (EIP) |
| Staff site | libadmin.yourdomain.com |
Elastic IP (EIP) |
Cloudflare Example
- Open your domain in Cloudflare
- Go to DNS
- Click Add record
- Type: A
- Name:
library(OPAC) orlibadmin(staff) - Paste the Elastic IP into “IPv4 address”
- Set Proxy Status to DNS only
- Save
Cloudflare usually updates within seconds.
A4. Continue Deployment
After your DNS A records are pointing to the Elastic IP, CloudFormation will complete the setup. Your OPAC and staff domains should start loading over HTTP.
Method B: Custom Domain Setup After Deployment (CLI Tool)
Use this method if:
- Your DNS was not ready during the initial deployment
- You want to change your domain later
- You prefer manual configuration
B1. Access the EC2 Instance via EC2 Instance Connect
This requires no SSH key.
- Open AWS Console → EC2
- Click Instances
- Select your Koha instance
- Click Connect
- Choose the EC2 Instance Connect tab
- Click Connect
You will see a command-line terminal in your browser.
B2. Run the Domain Setup Command
Use this command to configure or reconfigure your custom domain:
koha-setup-domains --domain yourdomain.com \ --opac-subdomain library \ --staff-subdomain libadmin
This updates the Apache virtual host configuration immediately. You can run it multiple times if you change DNS records or need corrections.
7. Verify Domain Resolution
Use these commands to confirm that each domain correctly points to the server:
dig library.yourdomain.com nslookup libadmin.yourdomain.com curl -I http://library.yourdomain.com
Each result should show the Elastic IP assigned to your Koha server.
8. Troubleshooting
- Wrong page or default Apache page appears:
Ensure your DNS record type is A, not CNAME.
Re-run the tool:koha-setup-domains --domain yourdomain.com - Nothing loads:
Check whether the Elastic IP has changed or been released. - DNS not propagating:
Check the TTL on your DNS provider.