Hosting connectors¶
Configure where Silex publishes built websites.
Overview¶
Hosting connectors handle publication: they receive the compiled HTML, CSS, and assets and deploy them to a live URL. Silex includes four built-in connectors:
- Filesystem — Write to local disk (for static file serving)
- Download — Generate a ZIP file for manual deployment
- GitLab Pages — Auto-publish to GitLab Pages via CI/CD
- FTP — Upload directly to an FTP server
Unlike storage connectors, hosting is typically a one-way operation: Silex publishes to it but doesn't download from it.
Prerequisites¶
- Understanding of server configuration
- Understanding of storage connectors
- For GitLab Pages: a GitLab account with CI/CD enabled
HostingConnector interface¶
All hosting connectors implement this interface:
export interface HostingConnector extends Connector {
publish(
session,
websiteId,
files,
jobManager
): Promise<JobData>
getUrl(session, websiteId): Promise<string>
// Plus standard auth methods (isLoggedIn, setToken, etc.)
}
Filesystem hosting¶
Write published sites to a local directory for web server integration.
Setup¶
Or in Docker:
environment:
HOSTING_CONNECTORS: fs
SILEX_FS_HOSTING_ROOT: /silex/hosting
volumes:
- ./silex-hosting:/silex/hosting
How it works¶
When a user publishes:
- Silex compiles the website (build awesome (powered by Eleventy))
- Files are written to
{SILEX_FS_HOSTING_ROOT}/{websiteId}/ - A web server (Nginx, Apache) can serve this directory publicly
Directory structure:
silex/hosting/
├── my-site-1/
│ ├── index.html
│ ├── about.html
│ ├── css/
│ │ └── style.css
│ └── assets/
│ ├── logo.png
│ └── hero.jpg
├── my-site-2/
│ ├── index.html
│ └── ...
Serving published sites¶
With Nginx¶
Create a server block in /etc/nginx/sites-available/silex-sites:
server {
listen 80;
server_name *.example.com;
# Route each subdomain to a published site directory
set $site_name $host;
set $site_name ${}; # Extract subdomain
root /silex/hosting;
try_files /$site_name$uri /$site_name/index.html =404;
}
Or manually add domains:
server {
listen 80;
server_name my-site-1.example.com;
root /silex/hosting/my-site-1;
try_files $uri $uri/ /index.html =404;
}
server {
listen 80;
server_name my-site-2.example.com;
root /silex/hosting/my-site-2;
try_files $uri $uri/ /index.html =404;
}
Reload Nginx:
With Apache¶
Create a virtual host file:
<VirtualHost *:80>
ServerName my-site.example.com
DocumentRoot /silex/hosting/my-site
<Directory /silex/hosting/my-site>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</Directory>
</VirtualHost>
Enable the site:
Configuration in code¶
const FsHosting = require('@silexlabs/silex/dist/server/connectors/FsHosting').FsHosting
module.exports = async function (config) {
config.setHostingConnectors([
new FsHosting(config, {
path: process.env.SILEX_FS_HOSTING_ROOT || './silex/hosting',
}),
])
}
Download connector¶
Generate a ZIP file for users to download and deploy manually.
Setup¶
How it works¶
When a user publishes:
- Silex compiles the website (build awesome)
- Files are zipped
- A download link is provided in the UI
- User downloads and extracts to their hosting
No special configuration needed. The download connector is built-in.
Use cases¶
- Deploy to Netlify, Vercel, or other static hosts
- Deploy to traditional hosting with FTP/SFTP
- Local development and testing
See Deploying to other hosting platforms for manual deployment instructions.
GitLab Pages hosting¶
Auto-publish to GitLab Pages via CI/CD.
Prerequisites¶
- GitLab repository in your storage connector
- CI/CD pipeline that runs build awesome and builds the site
- GitLab Pages enabled for your project
Setup¶
HOSTING_CONNECTORS=gitlab
GITLAB_CLIENT_ID=your-app-id
GITLAB_CLIENT_SECRET=your-app-secret
GITLAB_DOMAIN=gitlab.com
Same OAuth app as storage GitLab connector.
How it works¶
- User connects with GitLab (OAuth)
- Website is stored in a GitLab repository
- When user publishes, Silex:
- Commits the website source to the repo
- Triggers the CI/CD pipeline (
.gitlab-ci.yml) - Pipeline runs
npm run build(build awesome compilation) - Pipeline deploys to GitLab Pages
- Site is live at
https://username.gitlab.io/project-name
.gitlab-ci.yml¶
Silex provides a default CI/CD config. You can customize it. See GitLab CI/CD customization.
Custom domain¶
In your GitLab project settings:
- Go to Deployments → Pages
- Click New domain
- Enter your domain (e.g.,
my-site.com) - Follow DNS setup instructions
Configuration in code¶
const GitlabHostingConnector = require('@silexlabs/silex-plugins').GitlabHostingConnector
module.exports = async function (config) {
config.addHostingConnector(
new GitlabHostingConnector(config, {
clientId: process.env.GITLAB_CLIENT_ID,
clientSecret: process.env.GITLAB_CLIENT_SECRET,
domain: process.env.GITLAB_DOMAIN || 'gitlab.com',
})
)
}
FTP hosting¶
Upload directly to an FTP server.
Prerequisites¶
- FTP server with credentials and disk space
Setup¶
Or in Docker:
How it works¶
- User connects with FTP credentials (host, port, username, password)
- When user publishes:
- Silex compiles the website (build awesome)
- Files are uploaded via FTP to
{FTP_HOSTING_PATH}/{websiteId}/ - Site is immediately live (if web server is configured)
Typical FTP setup¶
public_html/
├── my-site-1/
│ ├── index.html
│ ├── css/style.css
│ └── assets/
├── my-site-2/
│ ├── index.html
│ └── ...
With DNS pointing my-site-1.com to your FTP server, the site is live at my-site-1.com/my-site-1/.
Configuration in code¶
const FtpConnector = require('@silexlabs/silex-plugins').FtpConnector
const { ConnectorType } = require('@silexlabs/silex/dist/server/types')
module.exports = async function (config) {
config.addHostingConnector(
new FtpConnector(config, {
type: ConnectorType.HOSTING,
path: process.env.FTP_HOSTING_PATH || '/public_html',
})
)
}
Comparison table¶
| Feature | Filesystem | Download | GitLab Pages | FTP |
|---|---|---|---|---|
| Setup | Simple | Built-in | Medium (OAuth) | Simple |
| Automation | Manual | Manual | Automatic (CI/CD) | Automatic |
| Cost | Your server | Free | Free | Your FTP |
| Custom domain | Manual DNS | Manual | GitLab UI | Manual DNS |
| Scaling | Single server | File download | GitLab infra | Your server |
| Best for | Self-hosted | Testing | Teams + GitHub | Traditional hosting |
Combining storage and hosting¶
Mix and match connectors for flexibility:
Users can store on GitLab and publish to FTP, or store locally and download as ZIP.
Job management¶
Hosting connectors receive a jobManager to track publication progress:
interface JobManager {
addJob(data: JobData): string
setJobData(jobId: string, data: JobData): void
getJobData(jobId: string): JobData | null
}
The connector updates job status as publication progresses. See server events for listening to publication lifecycle.
Troubleshooting¶
GitLab Pages not deployed¶
Check:
- .gitlab-ci.yml exists in the repo
- CI/CD is enabled in GitLab project settings
- Pipeline succeeded (check CI/CD → Pipelines)
- Pages are enabled (Deployments → Pages)
FTP upload failing¶
Verify:
- FTP server is reachable: telnet ftp.example.com 21
- Credentials are correct
- Disk space available on FTP server
- Path exists: cd /public_html in FTP client
Filesystem hosting not accessible¶
If sites are written but not visible:
- Check permissions:
ls -la ./silex/hosting/ - Verify web server is running and configured to serve the directory
- Check web server logs for errors
See also¶
- Storage connector setup
- Server configuration
- GitLab CI/CD customization — GitLab CI customization
- Deploying to other hosting platforms — Deploying to other platforms