This project is a voucher code captive portal for UniFi networks.
To run the captive portal, you will need:
- A UniFi controller
- A webserver reachable from the guest network
- Docker installed on the webserver
- Pull the latest Docker image from Docker Hub:
docker pull carlgo11/guest-portal
- Create a .env file with the following environment variables:
- Run the Docker container, mounting the .env file:
docker run -d \ -p 80:3000 \ --env-file .env \ carlgo11/guest-portal
- Access the captive portal through the webserver's URL.
- Create a
.env
file with the environment variables found under Configuration. - Create a
docker-compose.yml
file with the following data:version: '3.8' services: redis: image: redis:alpine volumes: - redis:/data node: image: carlgo11/guest-portal ports: - 3001:3000 env_file: .env volumes: redis:
By default, the captive portal fetches the Bing Image of the Day to use as the background. If you prefer to use your own background images, follow these steps:
The captive portal can display use different backgrounds depending on the season. If you wish to use this, follow these steps:
-
Create a new directory with the following subdirectories:
Spring
Summer
Autumn
Winter
-
Place your desired background images inside these folders. The client will automatically select the appropriate background image based on the browser window resolution.
-
Specify which hemisphere you're in (
north
orsouth
) in the.env
file. This is necessary to calculate the current season accurately. -
Link the parent directory of your custom background images to
/app/public/img/backgrounds/
in the Docker container. If using docker, you can link the directory by adding the following line to the docker command:docker run -d \ -p 80:3000 \ --env-file .env \ + -v $(pwd)/backgrounds:/app/public/img/backgrounds \ carlgo11/guest-portal
If using Docker Compose, link the directory by adding the following lines to
docker-compose.yml
:version: '3.8' services: redis: image: redis:alpine volumes: - redis:/data node: image: carlgo11/guest-portal + volumes: + - ./backgrounds:/app/public/img/background ports: - 3001:3000 env_file: .env volumes: redis:
-
Create a new directory and place your desired background images inside this directory. The client will automatically select the appropriate background image based on the browser window resolution.
-
Link the directory containing your background images to
/app/public/img/backgrounds/
in the Docker container. If using the Docker CLI, you can link the directory by adding the following line to the docker command:docker run -d \ -p 80:3000 \ --env-file .env \ + -v $(pwd)/backgrounds:/app/public/img/backgrounds \ carlgo11/guest-portal
The captive portal can be configured using the following environment variables:
Variable | Description | Default Value |
---|---|---|
HEMISPHERE |
Hemisphere setting for seasonal background selection | |
IMG_PATH |
Path to background images | img/background |
ORIGIN |
Origin URL for WebAuthn | http://localhost:3000 |
UNIFI_HOST |
UniFi controller host IP address | |
UNIFI_PORT |
UniFi controller port | 443 |
UNIFI_TLS |
Enable TLS for UniFi controller | false |
UNIFI_USERNAME |
Username for UniFi controller authentication | |
UNIFI_PASSWORD |
Password for UniFi controller authentication | |
UNIFI_SITE |
UniFi site name | default |
UNIFI_SSID |
WLAN SSID name | |
REDIS_HOST |
Redis server host | redis |
REDIS_PORT |
Redis server port | 6379 |
- Users connect to the guest Wi-Fi network.
- They are redirected to the captive portal login page.
- Users enter the voucher code provided by the administrator.
- Upon successful authentication, users are granted access to the internet.