Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ version: '3.9'
services:
nginx:
build: https://github.com/specify/nginx-with-github-auth.git#main
# build:
# context: ~/nginx-with-github-auth
ports:
- '80:80'
- '443:443'
volumes:
- './sp7-stats/config/auth.conf:/etc/nginx/auth.conf:ro'
- './sp7-stats/config/nginx.conf:/etc/nginx/conf.d/default.conf:ro'
- './sp7-stats/:/var/www/:ro'
- './sp7-stats/config/fullchain.pem:/etc/letsencrypt/live/sp7-stats/fullchain.pem:ro'
- './sp7-stats/config/privkey.pem:/etc/letsencrypt/live/sp7-stats/privkey.pem:ro'
# - './sp7-stats/config/fullchain.pem:/etc/letsencrypt/live/sp7-stats/fullchain.pem:ro'
# - './sp7-stats/config/privkey.pem:/etc/letsencrypt/live/sp7-stats/privkey.pem:ro'
- '/etc/letsencrypt:/etc/letsencrypt:ro'
- './access-logs/:/var/log/nginx/external/:rw'
networks:
- nginx
depends_on:
Expand Down
5 changes: 3 additions & 2 deletions sp7-stats/components/institutions.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ function compile_institutions($lines_data, $file_name){
$institution = $line_data['institution'];
$discipline = $line_data['discipline'];
$collection = $line_data['collection'];
$isa_number = $line_data['isaNumber'];
// $isa_number = $line_data['isaNumber'];
$isa_number = $line_data['isaNumber'] ?? '';
$browser = $line_data['browser'];
$domain = $line_data['domain'];
$os = $line_data['os'];
Expand Down Expand Up @@ -293,4 +294,4 @@ function sort_months($x,$y){
file_put_contents(WORKING_LOCATION.'institutions_id.json',json_encode($institutions4));
file_put_contents(WORKING_LOCATION.'institutions.json',json_encode($institutions3));

}
}
48 changes: 40 additions & 8 deletions sp7-stats/config/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
# Outbound DNS for Lua http requests
# resolver 1.1.1.1 8.8.8.8 valid=300s;
# resolver_timeout 5s;

# Trust store path on Alpine (nginx:alpine puts the bundle here)
# lua_ssl_trusted_certificate /etc/ssl/cert.pem;
# lua_ssl_verify_depth 5;

# See https://github.com/specify/nginx-with-github-auth
include nginx-with-github-auth/http.conf;

# Redirect HTTP to HTTPs
# --- HTTP (port 80) ---
server {
listen 80 default_server;
server_name _;
return 301 https://$host$request_uri;
listen [::]:80 default_server;

server_name stats.specifycloud.org;

# Serve ACME challenge over HTTP without redirect
location ^~ /.well-known/acme-challenge/ {
root /var/www/stats;
try_files $uri =404;
}

# Everything else: redirect to HTTPS
location / {
return 301 https://$host$request_uri;
}
}

# --- HTTPS (port 443) ---
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;

server_name stats.specifycloud.org;

# Use the certbot-standard live path for THIS domain name
ssl_certificate /etc/letsencrypt/live/stats.specifycloud.org-0001/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/stats.specifycloud.org-0001/privkey.pem;

ssl_certificate /etc/letsencrypt/live/sp7-stats/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sp7-stats/privkey.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_prefer_server_ciphers on;
Expand All @@ -21,19 +47,25 @@ server {
include nginx-with-github-auth/server.conf;

index index.php index.html;
server_name sp7-stats;
keepalive_timeout 70;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/;

# -- added
access_log /var/log/nginx/external/access.log combined;
location = /capture {
# access_log /var/log/nginx/capture.log; # optional separate log
access_log /var/log/nginx/external/access.log combined;
add_header Content-Type text/plain;
return 204;
}

location ~ ^/.+\.php$ {
include nginx-with-github-auth/location.conf;

include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}

}
3 changes: 2 additions & 1 deletion sp7-stats/cron/refresh_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
global $no_gui;
$no_gui = TRUE;

require_once('../refresh_data/index.php');
//require_once('../refresh_data/index.php');
require_once __DIR__ . '/../refresh_data/index.php';
17 changes: 11 additions & 6 deletions sp7-stats/refresh_data/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

require_once('../components/header.php');
//require_once('../components/header.php');
require_once dirname(__DIR__) . '/components/header.php';

date_default_timezone_set('UTC');
//date_default_timezone_set('America/Chicago');
Expand Down Expand Up @@ -74,19 +75,23 @@ function prepare_dir($dir,$delete_files=TRUE){
unset($_GET,$_POST,$_FILES,$_SERVER,$_COOKIE);

//prepare to extract data
require_once('../components/raw_data.php');
//require_once('../components/raw_data.php');
require_once dirname(__DIR__) . '/components/raw_data.php';

//prepare to compile institutions
require_once('../components/institutions.php');
//require_once('../components/institutions.php');
require_once dirname(__DIR__) . '/components/institutions.php';

//prepare to fetch information about user agent strings
require_once('../components/user_agent_strings.php');
//require_once('../components/user_agent_strings.php');
require_once dirname(__DIR__) . '/components/user_agent_strings.php';

//unzip all files
//run extract_data on each file
//run compile_institutions on each resulting file
//run get_data_for_user_agent_string and save new strings
require_once('../components/unzip.php');
//require_once('../components/unzip.php');
require_once dirname(__DIR__) . '/components/unzip.php';



Expand Down Expand Up @@ -115,4 +120,4 @@ function prepare_dir($dir,$delete_files=TRUE){

alert('info','Current RAM usage: '.round(memory_get_usage()/1024/1024,2).
'MB<br>Max RAM usage: '.round(memory_get_peak_usage()/1024/1024,2).
'MB<br>RAM usage limit: '.ini_get('memory_limit'));
'MB<br>RAM usage limit: '.ini_get('memory_limit'));