-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef0b760
commit 158646e
Showing
34 changed files
with
4,989 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
# See https://docs.docker.com/compose/environment-variables/#the-env-file | ||
|
||
# Nginx | ||
#NGINX_HOST=localhost | ||
|
||
# PHP | ||
|
||
# See https://hub.docker.com/r/nanoninja/php-fpm/tags/ | ||
#PHP_VERSION=latest | ||
|
||
# MySQL | ||
# mySQL default credentials for the container (accordingly to config.php) | ||
MYSQL_VERSION=5.7.22 | ||
MYSQL_HOST=mysql | ||
#MYSQL_DATABASE=test | ||
MYSQL_ROOT_USER=root | ||
MYSQL_ROOT_PASSWORD=root | ||
MYSQL_USER=espresso | ||
MYSQL_PASSWORD=lattecaffee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
version: '3' | ||
services: | ||
web: | ||
# build: | ||
# context: . | ||
# dockerfile: php_custom.Dockerfile | ||
image: nginx:latest | ||
container_name: guest_portal_nginx | ||
ports: | ||
- "80:80" | ||
volumes: | ||
- ./volumes/nginx/code:/code | ||
- ./volumes/nginx/conf/site.conf:/etc/nginx/conf.d/000_site.conf | ||
links: | ||
- php | ||
- mysqldb | ||
depends_on: | ||
- mysqldb | ||
php: | ||
build: | ||
context: . | ||
dockerfile: php_custom.Dockerfile | ||
# image: php:7-fpm | ||
container_name: guest_portal_php | ||
volumes: | ||
- ./volumes/nginx/code:/code | ||
links: | ||
- mysqldb | ||
mysqldb: | ||
image: mysql:${MYSQL_VERSION} | ||
container_name: guest_portal_${MYSQL_HOST} | ||
restart: always | ||
env_file: | ||
- ".env" | ||
environment: | ||
- MYSQL_DATABASE=${MYSQL_DATABASE} | ||
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} | ||
- MYSQL_USER=${MYSQL_USER} | ||
- MYSQL_PASSWORD=${MYSQL_PASSWORD} | ||
# ports: | ||
# - "8989:3306" | ||
volumes: | ||
- "./volumes/mysql/data:/var/lib/mysql" | ||
- ./import_db.sql:/docker-entrypoint-initdb.d/dump.sql | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
-- MySQL dump 10.13 Distrib 8.0.16, for Win64 (x86_64) | ||
-- | ||
-- Host: 192.168.99.21 Database: portal | ||
-- ------------------------------------------------------ | ||
-- Server version 5.7.25 | ||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
SET NAMES utf8 ; | ||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; | ||
/*!40103 SET TIME_ZONE='+00:00' */; | ||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; | ||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; | ||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; | ||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
|
||
-- | ||
-- Table structure for table `sessions` | ||
-- | ||
CREATE DATABASE `portal`; | ||
USE `portal`; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON `portal`.* TO `espresso`@`%`; | ||
|
||
DROP TABLE IF EXISTS `sessions`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
SET character_set_client = utf8mb4 ; | ||
CREATE TABLE `sessions` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`username` varchar(45) DEFAULT NULL, | ||
`mac` varchar(45) DEFAULT NULL, | ||
`ap` varchar(45) DEFAULT NULL, | ||
`timestamp` datetime DEFAULT NULL, | ||
PRIMARY KEY (`id`), | ||
KEY `username_idx` (`username`), | ||
KEY `id` (`id`), | ||
CONSTRAINT `username` FOREIGN KEY (`username`) REFERENCES `users` (`username`) ON DELETE NO ACTION ON UPDATE NO ACTION | ||
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
|
||
-- | ||
-- Dumping data for table `sessions` | ||
-- | ||
|
||
LOCK TABLES `sessions` WRITE; | ||
/*!40000 ALTER TABLE `sessions` DISABLE KEYS */; | ||
/*!40000 ALTER TABLE `sessions` ENABLE KEYS */; | ||
UNLOCK TABLES; | ||
|
||
-- | ||
-- Table structure for table `users` | ||
-- | ||
|
||
DROP TABLE IF EXISTS `users`; | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
SET character_set_client = utf8mb4 ; | ||
CREATE TABLE `users` ( | ||
`username` varchar(45) NOT NULL, | ||
`hash` varchar(255) DEFAULT NULL, | ||
`sessions` int(11) NOT NULL DEFAULT '0', | ||
`enabled` tinyint(1) NOT NULL DEFAULT '1', | ||
PRIMARY KEY (`username`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
/*!40101 SET character_set_client = @saved_cs_client */; | ||
|
||
-- | ||
-- Dumping data for table `users` | ||
-- | ||
|
||
LOCK TABLES `users` WRITE; | ||
/*!40000 ALTER TABLE `users` DISABLE KEYS */; | ||
/*!40000 ALTER TABLE `users` ENABLE KEYS */; | ||
UNLOCK TABLES; | ||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; | ||
|
||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; | ||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; | ||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; | ||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; | ||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; | ||
|
||
-- Dump completed on 2020-02-20 15:01:27 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
|
||
FROM php:7.2-fpm | ||
RUN docker-php-ext-install -j$(nproc) mysqli | ||
RUN docker-php-ext-install -j$(nproc) pdo | ||
RUN docker-php-ext-install -j$(nproc) pdo_mysql | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Inhalt der Datei: | ||
server { | ||
index index.php index.html; | ||
server_name _; | ||
error_log /var/log/nginx/error.log; | ||
access_log /var/log/nginx/access.log; | ||
root /code; | ||
|
||
location ~ \.php$ { | ||
try_files $uri =404; | ||
fastcgi_split_path_info ^(.+\.php)(/.+)$; | ||
fastcgi_pass php:9000; | ||
fastcgi_index index.php; | ||
include fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
fastcgi_param PATH_INFO $fastcgi_path_info; | ||
} | ||
location /config { | ||
deny all; | ||
return 404; | ||
} | ||
location /html { | ||
deny all; | ||
return 404; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# P0rtality - UniFi compatible Captive Portal | ||
|
||
## Features | ||
|
||
* Add & Remove Users | ||
* COMING SOON - Easy way to use existing user database | ||
* Get live Sessions of logged in Users | ||
* Kick logged in Users | ||
* basic session logging | ||
* docker support | ||
|
||
![alt text](./documentation/images/guest_login.png "Guest Login Example") | ||
![alt text](./documentation/images/admin_panel.png "Admin Panel") | ||
|
||
## Facts & Structure | ||
* nginx & PHP runs Front- and Backend | ||
* Mysql stores users, passwords and session-history | ||
* conf/config.php contains most settings | ||
|
||
## Compatibilty | ||
tested on Unifi | ||
* 5.12.35 | ||
* 5.12.66 | ||
|
||
## Installation | ||
|
||
### Docker | ||
* adapt **src/conf/config.php** BEFORE proceeding! | ||
* | ||
* run **run.compose.sh** | ||
* set IP of UniFi-Guest-Portal to the IP of your Docker-Host. (Unfi-Controller "Guest Conrol" - enable - "external Portal" - set IP) | ||
|
||
#### Testing | ||
* Portal is available at <IP>/guest/s/default/ | ||
|
||
|
||
nginx config, conf/config.php and all web-content is mounted in **volumes/nginx** afterwards. | ||
|
||
|
||
### Manual Installation | ||
* Make the contents of the **src**-folder available via web server. The root directory (where the .php files live) must be accessible under <domain/IP>/guest/s/default/. PHP is needed. | ||
* Prevent direct access to the directories **html** and **config**! | ||
* import **.build/import_db.sql** into a **Medoo** compatible database. | ||
* adapt **conf/config.php**. | ||
|
||
## Credits | ||
this project uses | ||
* Medoo for DB-Access (http://medoo.in/) | ||
* parts of the UniFi API browser for Unifi-Controller API Logic (https://github.com/Art-of-WiFi/UniFi-API-browser) | ||
|
||
and is inspired by | ||
* espresso-portal (https://github.com/emanuelepaiano/espresso-portal) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
mkdir .build/volumes/mysql | ||
mkdir .build/volumes/mysql/data | ||
|
||
mkdir .build/volumes/nginx/code | ||
mkdir .build/volumes/nginx/code/guest | ||
mkdir .build/volumes/nginx/code/guest/s | ||
mkdir .build/volumes/nginx/code/guest/s/default | ||
|
||
cp -R src/* .build/volumes/nginx/code/guest/s/default/ | ||
cd .build | ||
docker-compose -p guest_portal up -d |
Oops, something went wrong.