chore: import upstream snapshot with attribution
CI / compile_and_lint (push) Failing after 0s
CI / docker_build (linux/amd64, -linux-amd64-duckdb, duckdb) (push) Failing after 0s
CI / docker_build (linux/arm64, -linux-arm64, minimal) (push) Failing after 2s
CI / docker_build (linux/arm64, -linux-arm64-duckdb, duckdb) (push) Failing after 1s
CI / docker_build (linux/amd64, minimal) (push) Failing after 1s
CI / test (, sqlite, sqlite::memory:) (push) Has been skipped
CI / test (mssql, mssql, mssql://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / test (mysql, mysql, mysql://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / test (oracle, oracle, Driver=Oracle 21 ODBC driver;Dbq=//127.0.0.1:1521/FREEPDB1;Uid=root;Pwd=Password123!) (push) Has been skipped
CI / test (postgres, odbc, Driver=PostgreSQL Unicode;Server=127.0.0.1;Port=5432;Database=sqlpage;UID=root;PWD=Password123!, true) (push) Has been skipped
CI / test (postgres, postgres, postgres://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / playwright (push) Has been skipped
CI / docker_build (linux/arm/v7, -linux-arm-v7, minimal) (push) Failing after 0s
CI / hurl_examples (push) Failing after 8s
deploy website / deploy_official_site (push) Failing after 1s
CI / hurl (${{ matrix.example }}) (push) Has been skipped
CI / docker_push (duckdb) (push) Has been cancelled
CI / docker_push (minimal) (push) Has been cancelled
CI / windows_test (push) Has been cancelled
CI / compile_and_lint (push) Failing after 0s
CI / docker_build (linux/amd64, -linux-amd64-duckdb, duckdb) (push) Failing after 0s
CI / docker_build (linux/arm64, -linux-arm64, minimal) (push) Failing after 2s
CI / docker_build (linux/arm64, -linux-arm64-duckdb, duckdb) (push) Failing after 1s
CI / docker_build (linux/amd64, minimal) (push) Failing after 1s
CI / test (, sqlite, sqlite::memory:) (push) Has been skipped
CI / test (mssql, mssql, mssql://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / test (mysql, mysql, mysql://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / test (oracle, oracle, Driver=Oracle 21 ODBC driver;Dbq=//127.0.0.1:1521/FREEPDB1;Uid=root;Pwd=Password123!) (push) Has been skipped
CI / test (postgres, odbc, Driver=PostgreSQL Unicode;Server=127.0.0.1;Port=5432;Database=sqlpage;UID=root;PWD=Password123!, true) (push) Has been skipped
CI / test (postgres, postgres, postgres://root:Password123!@127.0.0.1/sqlpage) (push) Has been skipped
CI / playwright (push) Has been skipped
CI / docker_build (linux/arm/v7, -linux-arm-v7, minimal) (push) Failing after 0s
CI / hurl_examples (push) Failing after 8s
deploy website / deploy_official_site (push) Failing after 1s
CI / hurl (${{ matrix.example }}) (push) Has been skipped
CI / docker_push (duckdb) (push) Has been cancelled
CI / docker_push (minimal) (push) Has been cancelled
CI / windows_test (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
# SQLPage with Apache Reverse Proxy
|
||||
|
||||
This example demonstrates how to run SQLPage behind the popular Apache HTTP Server.
|
||||
This is particularly useful when you already have a server running Apache (with a PHP application for example)
|
||||
and you want to add a SQLPage application.
|
||||
|
||||
This setup allows you to:
|
||||
- Host multiple websites/applications on a single server
|
||||
- Serve static files directly through Apache
|
||||
- Route specific paths to SQLPage
|
||||
|
||||
## How it Works
|
||||
|
||||
Apache acts as a reverse proxy, forwarding requests for `/my_website` to the SQLPage
|
||||
application while serving static content directly. The configuration uses:
|
||||
|
||||
- [`mod_proxy`](https://httpd.apache.org/docs/current/mod/mod_proxy.html) and [`mod_proxy_http`](https://httpd.apache.org/docs/current/mod/mod_proxy_http.html) for reverse proxy functionality
|
||||
- [Virtual hosts](https://httpd.apache.org/docs/current/vhosts/) for domain-based routing
|
||||
- [`ProxyPass`](https://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass) directives to forward specific paths
|
||||
|
||||
## Docker Setup
|
||||
|
||||
The `docker-compose.yml` defines three services:
|
||||
- `apache`: Serves static content and routes requests
|
||||
- `sqlpage`: Handles dynamic content generation
|
||||
- `mysql`: Provides database storage
|
||||
|
||||
## Native Apache Setup
|
||||
|
||||
To use this with a native Apache installation instead of Docker:
|
||||
|
||||
1. Install Apache and required modules:
|
||||
```bash
|
||||
sudo apt install apache2
|
||||
sudo a2enmod proxy proxy_http
|
||||
```
|
||||
|
||||
2. Configuration changes:
|
||||
- Place the `httpd.conf` content in `/etc/apache2/sites-available/my-site.conf`
|
||||
- Adjust paths:
|
||||
- Change `/var/www` to your static files location
|
||||
- Update SQLPage URL to match your actual SQLPage server address (`http://localhost:8080/my_website` if you are running sqlpage locally)
|
||||
- Modify log paths to standard Apache locations (`/var/log/apache2/`)
|
||||
|
||||
3. SQLPage setup:
|
||||
- Install SQLPage on your server
|
||||
- Configure it with the same `site_prefix` in `sqlpage.json`
|
||||
- Ensure MySQL is accessible from the SQLPage instance
|
||||
|
||||
4. Enable the site:
|
||||
```bash
|
||||
sudo a2ensite my-site
|
||||
sudo systemctl reload apache2
|
||||
```
|
||||
|
||||
## Files Overview
|
||||
|
||||
- `httpd.conf`: Apache configuration with proxy rules
|
||||
- `sqlpage_config/sqlpage.json`: SQLPage configuration with URL prefix
|
||||
- `static/`: Static files served directly by Apache
|
||||
- `website/`: SQLPage SQL files for dynamic content
|
||||
@@ -0,0 +1,39 @@
|
||||
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
|
||||
LoadModule proxy_module modules/mod_proxy.so
|
||||
LoadModule proxy_http_module modules/mod_proxy_http.so
|
||||
LoadModule unixd_module modules/mod_unixd.so
|
||||
LoadModule log_config_module modules/mod_log_config.so
|
||||
LoadModule authz_core_module modules/mod_authz_core.so
|
||||
LoadModule dir_module modules/mod_dir.so
|
||||
|
||||
<IfModule unixd_module>
|
||||
User daemon
|
||||
Group daemon
|
||||
</IfModule>
|
||||
|
||||
ServerName localhost
|
||||
Listen 80
|
||||
|
||||
DirectoryIndex index.html
|
||||
|
||||
ErrorLog /proc/self/fd/2
|
||||
LogLevel warn
|
||||
CustomLog /proc/self/fd/1 combined
|
||||
|
||||
<VirtualHost *:80>
|
||||
ServerName my_website
|
||||
DocumentRoot "/var/www"
|
||||
|
||||
ProxyPreserveHost On
|
||||
|
||||
<Location />
|
||||
Require all granted
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride None
|
||||
</Location>
|
||||
|
||||
<Location /my_website>
|
||||
ProxyPass "http://sqlpage:8080/my_website"
|
||||
ProxyPassReverse "http://sqlpage:8080/my_website"
|
||||
</Location>
|
||||
</VirtualHost>
|
||||
@@ -0,0 +1,33 @@
|
||||
services:
|
||||
sqlpage:
|
||||
image: lovasoa/sqlpage:main
|
||||
volumes:
|
||||
- ./sqlpage_config:/etc/sqlpage:ro
|
||||
- ./website:/var/www:ro
|
||||
environment:
|
||||
- DATABASE_URL=mysql://sqlpage:sqlpage_password@mysql:3306/sqlpage_db
|
||||
depends_on:
|
||||
- mysql
|
||||
|
||||
apache:
|
||||
image: httpd:2.4
|
||||
ports:
|
||||
- "8080:80"
|
||||
volumes:
|
||||
- ./apache/httpd.conf:/usr/local/apache2/conf/httpd.conf:ro
|
||||
- ./static:/var/www:ro
|
||||
depends_on:
|
||||
- sqlpage
|
||||
|
||||
mysql:
|
||||
image: mysql:8
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=root_password
|
||||
- MYSQL_DATABASE=sqlpage_db
|
||||
- MYSQL_USER=sqlpage
|
||||
- MYSQL_PASSWORD=sqlpage_password
|
||||
volumes:
|
||||
- mysql_data:/var/lib/mysql
|
||||
|
||||
volumes:
|
||||
mysql_data:
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"site_prefix": "/my_website"
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Welcome</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: system-ui, sans-serif;
|
||||
text-align: center;
|
||||
margin: 40px;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
.main-link {
|
||||
display: inline-block;
|
||||
padding: 12px 24px;
|
||||
background: #4CAF50;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.main-link:hover {
|
||||
background: #89ca8c;
|
||||
}
|
||||
.info {
|
||||
max-width: 600px;
|
||||
margin: 20px auto;
|
||||
color: #666;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome to Our Site</h1>
|
||||
<p class="info">
|
||||
This page is served by Apache web server, which acts as a reverse proxy. When you click the button below,
|
||||
you'll be redirected to a SQLPage application running in a separate container. The setup includes three
|
||||
services: Apache for static content and routing, SQLPage for dynamic content, and MySQL for data storage.
|
||||
</p>
|
||||
<a href="/my_website" class="main-link">Enter Site</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,20 @@
|
||||
GET http://localhost:8080/
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
body contains "Welcome to Our Site"
|
||||
body contains "served by Apache web server"
|
||||
body contains "href=\"/my_website\""
|
||||
|
||||
GET http://localhost:8080/my_website
|
||||
HTTP 301
|
||||
[Asserts]
|
||||
header "Location" == "/my_website/"
|
||||
|
||||
GET http://localhost:8080/my_website/
|
||||
HTTP 200
|
||||
[Asserts]
|
||||
header "Content-Type" contains "text/html"
|
||||
body contains "Welcome to my website"
|
||||
body contains "Using SQLPage v"
|
||||
body contains "Connected to"
|
||||
body contains "MySQL"
|
||||
@@ -0,0 +1,9 @@
|
||||
select
|
||||
'text' as component,
|
||||
true as article,
|
||||
'
|
||||
# Welcome to my website
|
||||
|
||||
Using SQLPage v' || sqlpage.version() || '
|
||||
|
||||
Connected to **MySQL** v' || version () as contents_md;
|
||||
Reference in New Issue
Block a user