This repository contains the backend server for Aurion, written in Go.
It provides the API, authentication, key management, and integrations with the mail backend.
- Go 1.22+ (for development/building)
- PostgreSQL 15+
- Git
- Apache2 & Certbot (for production routing and SSL)
- (Optional) Air for hot‑reload (dev only)
Run the following commands in your PostgreSQL instance to initialize the database and user:
sudo -u postgres psql
CREATE USER aurionuser WITH PASSWORD 'coolpassword';
CREATE DATABASE auriondb OWNER aurionuser;
\c auriondb
GRANT ALL ON SCHEMA public TO aurionuser;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO aurionuser;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO aurionuser;
Note (ONLY for DEV): Remember to apply the database migrations if you are on dev environement. If you have
gooseinstalled:goose -dir internal/db/migrations postgres "host=localhost user=aurionuser password=coolpassword dbname=auriondb sslmode=disable" up
Clone the repository and create your configuration file:
git clone https://github.com/aurion/core.git
cd core
cp .env.example .env
Edit the .env file with your specific configuration:
APP_ENV=production # change to 'dev' for local development
APP_PORT=8080
DB_HOST=localhost
DB_PORT=5432
DB_USER=aurionuser
DB_PASS=coolpassword
DB_NAME=auriondb
MAIL_BACKEND=jmap
JMAP_URL=hello
# IMAP_URL=hello
STALWART_API_KEY=hello
# Generate a secure key using: openssl rand -base64 32
AUTH_FAKE_SALT_SECRET="e4jQQdVPo4+71ceUgE2K+6XHjbNJtj3pCP94BXjMIiY="
Install dependencies:
go mod tidy
go run ./cmd/app-server
Install Air first: go install github.com/air-verse/air@latest
air
The server will be available at: http://localhost:8080
For standard production usage, it is recommended to compile the Go binary rather than using go run.
Compile the application into a single executable:
go mod tidy
go build -ldflags="-w -s" -o aurion-core ./cmd/app-server
(The -ldflags="-w -s" flags strip debugging information to reduce the binary size).
To run the server, you only need the compiled aurion-core binary and the .env file in the same directory.
./aurion-core
To ensure the server runs continuously and restarts automatically on crash or reboot, create a systemd service.
Create the file /etc/systemd/system/aurion.service:
[Unit]
Description=Aurion Core Server
After=network.target postgresql.service
[Service]
Type=simple
User=www-data
WorkingDirectory=/var/www/aurion
ExecStart=/var/www/aurion/aurion-core
Restart=always
RestartSec=5
EnvironmentFile=/var/www/aurion/.env
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable aurion
sudo systemctl start aurion
In production, you should expose the server via a reverse proxy like Apache to handle SSL/TLS termination, custom domains, and headers.
Install Apache2 and ensure the mandatory proxy modules are enabled:
sudo apt update
sudo apt install apache2 -y
# Enable proxy modules
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod headers
sudo a2enmod rewrite
Create a new configuration file for your domain (e.g., api.aurion.example.com):
sudo nano /etc/apache2/sites-available/aurion.conf
Paste the following configuration (replace api.aurion.example.com with your real domain):
<VirtualHost *:80>
ServerName api.aurion.example.com
# Forward requests to the Go application running on port 8080
ProxyPreserveHost On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
# Security Headers
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options "DENY"
Header always set X-XSS-Protection "1; mode=block"
ErrorLog ${APACHE_LOG_DIR}/aurion-error.log
CustomLog ${APACHE_LOG_DIR}/aurion-access.log combined
</VirtualHost>
Enable the new site and restart Apache:
sudo a2ensite aurion.conf
sudo systemctl restart apache2
Install Certbot along with the Apache plugin to automatically fetch and configure your Let's Encrypt certificate:
sudo apt install certbot python3-certbot-apache -y
Run Certbot to generate the SSL certificate. Certbot will automatically read your Apache configuration, look for the ServerName, and prompt you to handle HTTPS redirection:
sudo certbot --apache -d api.aurion.example.com