diff --git a/README.md b/README.md index aaaa5fc..09b2cc9 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/config.dist.php b/config.dist.php index 5b7e2ec..b9f42ef 100644 --- a/config.dist.php +++ b/config.dist.php @@ -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; diff --git a/docker-compose.yml b/docker-compose.yml index cb5da1a..a53c2b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile index e06e03e..f9543be 100644 --- a/docker/nginx/Dockerfile +++ b/docker/nginx/Dockerfile @@ -1,3 +1,3 @@ FROM nginx:mainline-alpine -COPY nginx.conf /etc/nginx/nginx.conf +COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf index c95737e..3d70b27 100644 --- a/docker/nginx/nginx.conf +++ b/docker/nginx/nginx.conf @@ -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; diff --git a/docker/php-fpm/Dockerfile b/docker/php-fpm/Dockerfile index 8ba5f8a..6fdeb39 100644 --- a/docker/php-fpm/Dockerfile +++ b/docker/php-fpm/Dockerfile @@ -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 diff --git a/docker/php-fpm/src/config.php b/docker/php-fpm/src/config.php index 1cab635..02ad439 100644 --- a/docker/php-fpm/src/config.php +++ b/docker/php-fpm/src/config.php @@ -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; diff --git a/index.php b/index.php index 2572508..340fd68 100644 --- a/index.php +++ b/index.php @@ -130,7 +130,9 @@ $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(ran @@ -171,14 +173,14 @@ $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(ran