# π vServer - Functional Web Server on Go
**π·πΊ [Π ΡΡΡΠΊΠ°Ρ Π²Π΅ΡΡΠΈΡ](README.md)**
> Full-featured web server with HTTP/HTTPS, MySQL, PHP support and GUI admin panel
**π¨βπ» Author:** Roman Sumaneev
**π Website:** [voxsel.ru](https://voxsel.ru)
**π Contact:** [VK](https://vk.com/felias)
## π― Features
### π Web Server
- β
**HTTP/HTTPS** server with SSL certificate support
- β
**Proxy server** for request proxying
- β
**PHP server** with built-in PHP 8 support
- β
**Static content** for hosting websites
- β
**vAccess** - access control system for sites and proxies
### ποΈ Database
- β
**MySQL server** with full support
### π§ Administration
- β
**GUI Admin Panel** - Wails desktop application with modern interface
- β
**Service Management** - start/stop HTTP, HTTPS, MySQL, PHP, Proxy
- β
**Site and Proxy Editor** - visual configuration management
- β
**vAccess Editor** - access rules configuration through interface
## ποΈ Architecture
```
vServer/
βββ π― main.go # Main server entry point
β
βββ π§ Backend/ # Core logic
β β
β βββ admin/ # | ποΈ GUI Admin Panel (Wails) |
β β βββ go/ # | Go backend for admin panel |
β β βββ frontend/ # | Modern UI |
β β
β βββ config/ # | π§ Go configuration files |
β βββ tools/ # | π οΈ Utilities and helpers |
β βββ WebServer/ # | π Web server modules |
β
βββ π WebServer/ # Web content and configuration
β β
β βββ cert/ # | π SSL certificates |
β βββ soft/ # | π¦ MySQL and PHP |
β βββ tools/ # | π Logs and tools |
β βββ www/ # | π Web content |
β
βββ π go.mod # Go modules
βββ π¨ build_admin.ps1 # Build GUI admin panel
βββ π vSerf.exe # GUI admin panel (after build)
```
## π Installation and Launch
### π¨ Building the Main Server
```powershell
./build_admin.ps1
```
The script will automatically:
- Check/create `go.mod`
- Install dependencies (`go mod tidy`)
- Check/install Wails CLI
- Build the application β `vSerf.exe`
### π¦ Component Preparation
1. Extract `WebServer/soft/soft.rar` archive to `WebServer/soft/` folder
2. Run `vServer.exe` - main server
3. Run `vSerf.exe` - GUI admin panel for management
> π **Important:** Default MySQL password is `root`
### π¦ Ready Project for Users
Required for operation:
- π `vSerf.exe` - GUI admin panel (optional)
- π `WebServer/` - configuration and resources
> π‘ The `Backend/` folder and `go.mod`, `main.go` files are only needed for development
## βοΈ Configuration
Configuration via `WebServer/config.json`:
```json
{
"Site_www": [
{
"name": "Local Site",
"host": "127.0.0.1",
"alias": ["localhost"],
"status": "active",
"root_file": "index.html",
"root_file_routing": true
}
],
"Proxy_Service": [
{
"Enable": true,
"ExternalDomain": "git.example.com",
"LocalAddress": "127.0.0.1",
"LocalPort": "3333",
"ServiceHTTPSuse": false,
"AutoHTTPS": true
}
],
"Soft_Settings": {
"mysql_port": 3306, "mysql_host": "127.0.0.1",
"php_port": 8000, "php_host": "localhost",
"proxy_enabled": true
}
}
```
**Main Parameters:**
- `Site_www` - website settings
- `Proxy_Service` - proxy service configuration
- `Soft_Settings` - service ports and hosts (MySQL, PHP, proxy_enabled)
### π Alias with Wildcard Support
Wildcard (`*`) support in aliases for sites:
```json
{
"alias": [
"*.test.com", // All subdomains of test.com
"*.test.ru", // All subdomains of test.ru
"test.com", // Exact match
"api.*" // api with any zone
],
"host": "test.com"
}
```
**Wildcard Examples:**
- `*.example.com` β `api.example.com`, `admin.example.com`, `test.example.com` β
- `example.*` β `example.com`, `example.ru`, `example.org` β
- `*example.com` β `test-example.com`, `my-example.com` β
- `*` β any domain β
(use carefully!)
- `example.com` β only `example.com` β
(without wildcard)
### π Proxy Server
The proxy server allows redirecting external requests to local services.
**Proxy_Service Parameters:**
- `Enable` - enable/disable proxy (true/false)
- `ExternalDomain` - external domain for request interception
- `LocalAddress` - local service address
- `LocalPort` - local service port
- `ServiceHTTPSuse` - use HTTPS for connecting to local service (true/false)
- `AutoHTTPS` - automatically redirect HTTP β HTTPS (true/false)
**Multiple Proxy Example:**
```json
"Proxy_Service": [
{
"Enable": true,
"ExternalDomain": "git.example.com",
"LocalAddress": "127.0.0.1",
"LocalPort": "3000",
"ServiceHTTPSuse": false,
"AutoHTTPS": true
},
{
"Enable": false,
"ExternalDomain": "api.example.com",
"LocalAddress": "127.0.0.1",
"LocalPort": "8080",
"ServiceHTTPSuse": false,
"AutoHTTPS": false
}
]
```
#### π Detailed Parameter Description:
**`ServiceHTTPSuse`** - protocol for connecting to local service:
- `false` - vServer connects to local service via HTTP (default)
- `true` - vServer connects to local service via HTTPS
**`AutoHTTPS`** - automatic HTTPS redirect:
- `true` - all HTTP requests are automatically redirected to HTTPS (recommended)
- `false` - both HTTP and HTTPS requests are allowed
**How it Works:**
```
Client (HTTP/HTTPS) β vServer (AutoHTTPS check) β Local Service (ServiceHTTPSuse)
```
**Applying Changes:**
- Enter `config_reload` command in console to reload configuration
- Changes will apply to new requests without server restart
## π vAccess - Access Control System
vServer includes a flexible access control system **vAccess** for sites and proxy services.
### π Configuration Locations
**For Sites:**
```
WebServer/www/{host}/vAccess.conf
```
**For Proxy:**
```
WebServer/tools/Proxy_vAccess/{domain}_vAccess.conf
```
### βοΈ Main Features
- β
**IP Filtering** - allow/block by IP addresses
- β
**Path Control** - restrict access to specific directories
- β
**File Filtering** - block by extensions (*.php, *.exe)
- β
**Exceptions** - flexible rules with exceptions_dir
- β
**Custom Errors** - redirects or error pages
### π Configuration Example
```conf
# Allow admin panel only from local IPs
type: Allow
path_access: /admin/*, /api/admin/*
ip_list: 127.0.0.1, 192.168.1.100
url_error: 404
# Block dangerous files in uploads
type: Disable
type_file: *.php, *.exe, *.sh
path_access: /uploads/*
url_error: 404
```
### π Documentation
Detailed vAccess documentation:
- **For Sites:** see `WebServer/www/{host}/vAccess.conf` (examples in file)
- **For Proxy:** see `WebServer/tools/Proxy_vAccess/README.md`
## π Logging
All logs are saved in `WebServer/tools/logs/`:
- π `logs_http.log` - HTTP requests (including proxy P-HTTP)
- π `logs_https.log` - HTTPS requests (including proxy P-HTTPS)
- π `logs_proxy.log` - Proxy server errors
- ποΈ `logs_mysql.log` - MySQL operations
- π `logs_php.log` - PHP errors
- βοΈ `logs_config.log` - Configuration
- π `logs_vaccess.log` - Access control for sites
- π `logs_vaccess_proxy.log` - Access control for proxy
## π SSL Certificates
### Certificate Installation
1. Open `WebServer/` directory
2. Create `cert/` folder (if it doesn't exist)
3. Create a folder with your domain name or IP address
4. Place certificate files with **exact** names:
```
certificate.crt
private.key
ca_bundle.crt
```
5. Certificate will be automatically loaded at server startup
### π Certificate Structure
```
WebServer/
βββ cert/
βββ example.com/ # Main domain
β βββ certificate.crt
β βββ private.key
β βββ ca_bundle.crt
β
βββ sub.example.com/ # Subdomain (optional)
βββ certificate.crt
βββ private.key
βββ ca_bundle.crt
```
### π― Working with Subdomains
**Important:** If no separate folder is created in `cert/` for a subdomain, the parent domain's certificate will be used automatically.
**Examples:**
- β
Request to `example.com` β uses certificate from `cert/example.com/`
- β
Request to `sub.example.com` (folder exists) β uses `cert/sub.example.com/`
- β
Request to `sub.example.com` (folder does NOT exist) β uses `cert/example.com/`
**This is convenient for wildcard certificates:** one certificate in the main domain folder is enough for all subdomains! π