Merge pull request #41 from SalmonCloud/contrib

Docker Fixes, iPerf3 Feature Completion, Minor PHP Code Improvements
This commit is contained in:
Tamer 2024-04-27 18:47:51 +02:00 committed by GitHub
commit 24445308dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 46 additions and 17 deletions

View File

@ -29,7 +29,7 @@ Note: These steps also work with AlmaLinux 9, but it will install PHP 8 instead
1. Install the required network tools: `dnf install mtr traceroute -y`.
2. Install the web server with PHP (by default it will install 7.2 on RHEL 8): `dnf install httpd mod_ssl php php-posix -y`.
3. Enable and start Apache/PHP-FPM: `systemctl enable httpd; systemctl enable php-fpm` and `systemctl start httpd; systemctl start php-fpm`.
3. Enable and start Apache/PHP-FPM: `systemctl enable --now httpd && systemctl enable --now php-fpm`.
4. Let's help MTR to work, execute the following command: `ln -s /usr/sbin/mtr /usr/bin/mtr` and also mtr helper called mtr-packet: `ln -s /usr/sbin/mtr-packet /usr/bin/mtr-packet`.
5. You *must* configure SELinux before this all works, or you can disable SELinux using `setenforce 0` and possibly make it permanent: `nano /etc/selinux/config` change to `SELINUX=disabled`.
6. Upload the contents of the ZIP to /var/www/html/.
@ -47,6 +47,24 @@ For installation using Docker, follow these steps and run the commands on the ta
6. Create and start the containers: `docker compose up -d`.
7. Afterward, the Looking Glass should be reachable from your web browser at `http://$your_server_ip/`!
### iPerf3 Installation (Optional)
> It is recommended to install iPerf3 on a different server from your looking glass to avoid network congestion.
#### Manual
Again, we will assume that we are working on AlmaLinux 8 or 9.
1. Install iPerf3: `dnf install iperf3 -y`
2. Launch iPerf3 as a daemon: `iperf3 -sD -p 5201`.
3. (Optional) You might want to add a systemd unit file for iPerf3, so it automatically starts when the system boots up.
4. Locate the two lines containing `LG_SPEEDTEST_CMD_INCOMING` and `LG_SPEEDTEST_CMD_OUTGOING` respectively in `config.php`.
5. Change `hostname` in these lines to the IPv4 address of your iPerf3 server.
#### Docker
1. Uncomment the section for `iperf3` in `docker-compose.yml` if you want iPerf3 and the looking glass to be on the same server.
Otherwise, please copy the `iperf3` section and save it as `docker-compose.yml` on another server with Docker and Docker Compose installed.
2. Start the iPerf3 container: `docker compose up -d`.
3. Locate the two lines containing `LG_SPEEDTEST_CMD_INCOMING` and `LG_SPEEDTEST_CMD_OUTGOING` respectively in `docker/php-fpm/src/config.php`.
5. Change `hostname` in these lines to the IPv4 address of your iPerf3 server.
### Upgrading
Upgrading from a previous version is easy, simply overwrite your current installation with the new files. Then update your config.php accordingly, the script will automatically check for missing variables.

View File

@ -15,7 +15,7 @@ const LG_LOGO_URL = 'https://github.com/hybula/lookingglass/';
const LG_THEME = 'auto';
// Enable the latency check feature;
const LG_CHECK_LATENCY = false;
const LG_CHECK_LATENCY = true;
// Define a custom CSS file which can be used to style the LG, set false to disable, else point to the CSS file;
const LG_CSS_OVERRIDES = false;

View File

@ -1,20 +1,20 @@
version: "3.8"
services:
nginx:
image: hybula/lookingglass-nginx:1
container_name: lg-nginx
build:
context: docker/nginx
dockerfile: Dockerfile
ports:
- "80:80"
context: .
dockerfile: docker/nginx/Dockerfile
network_mode: host
restart: unless-stopped
php-fpm:
image: hybula/lookingglass-php:1
container_name: lg-php
build:
context: .
dockerfile: docker/php-fpm/Dockerfile
network_mode: host
restart: unless-stopped
environment:
# For a better reference as to what these variables do, check out 'config.dist.php' or 'docker/php-fpm/src/config.php'.
@ -33,3 +33,12 @@ services:
# ENABLE_CUSTOM_BLOCK: 'true'
# Uncomment if you require visitors to accept the Terms of Use; the value should be a link to the terms.
# LG_TERMS: http://localhost/
# iperf3:
# image: networkstatic/iperf3:latest
# container_name: lg-iperf3
# network_mode: host
# command: -s
# tty: true
# stdin_open: true
# restart: unless-stopped

View File

@ -1,3 +1,3 @@
FROM nginx:mainline-alpine
COPY nginx.conf /etc/nginx/nginx.conf
COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf

View File

@ -41,7 +41,7 @@ http {
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_pass localhost:9000;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_buffering on;

View File

@ -1,7 +1,7 @@
FROM php:8.1-fpm-bullseye
RUN apt-get update && \
apt-get --no-install-recommends -y install iputils-ping mtr traceroute && \
apt-get --no-install-recommends -y install iputils-ping mtr traceroute iproute2 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /var/www/html

View File

@ -15,7 +15,7 @@ const LG_LOGO_URL = 'https://github.com/hybula/lookingglass/';
const LG_THEME = 'auto';
// Enable the latency check feature;
const LG_CHECK_LATENCY = false;
const LG_CHECK_LATENCY = true;
// Define a custom CSS file which can be used to style the LG, set false to disable, else point to the CSS file;
const LG_CSS_OVERRIDES = false;

View File

@ -130,7 +130,9 @@ $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(ran
<select class="form-select" onchange="window.location = this.options[this.selectedIndex].value" <?php if (count($templateData['locations']) == 0) echo 'disabled'; ?>>
<option selected><?php echo $templateData['current_location'] ?></option>
<?php foreach ($templateData['locations'] as $location => $link): ?>
<option value="<?php echo $link ?>"><?php echo $location ?></option>
<?php if ($location !== $templateData['current_location']): ?>
<option value="<?php echo $link ?>"><?php echo $location ?></option>
<?php endif ?>
<?php endforeach ?>
</select>
</div>
@ -171,14 +173,14 @@ $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(ran
<div class="row mb-3">
<div class="col-md-3">
<label class="mb-2 text-muted">Test IPv4</label>
<label class="mb-2 text-muted">Looking Glass IPv4</label>
<div class="input-group">
<input type="text" class="form-control" value="<?php echo $templateData['ipv4'] ?>" onfocus="this.select()" readonly="">
<button class="btn btn-outline-secondary" onclick="copyToClipboard('<?php echo $templateData['ipv4'] ?>', this)">Copy</button>
</div>
</div>
<div class="col-md-5">
<label class="mb-2 text-muted">Test IPv6</label>
<label class="mb-2 text-muted">Looking Glass IPv6</label>
<div class="input-group">
<input type="text" class="form-control" value="<?php echo $templateData['ipv6'] ?>" onfocus="this.select()" readonly="">
<button class="btn btn-outline-secondary" onclick="copyToClipboard('<?php echo $templateData['ipv6'] ?>', this)">Copy</button>
@ -272,7 +274,7 @@ $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(ran
</div>
<?php endif ?>
<?php if (count($templateData['speedtest_files'])): ?>
<?php if (count($templateData['speedtest_files'])): ?>
<div class="row">
<label class="mb-2 text-muted">Test Files</label>
<div class="btn-group input-group mb-3">
@ -281,7 +283,7 @@ $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(ran
<?php endforeach ?>
</div>
</div>
<?php endif ?>
<?php endif ?>
</div>
</div>