Spaces:
Sleeping
Sleeping
Raymond Weitekamp
commited on
Commit
·
c88d551
1
Parent(s):
b9eab82
Add Nginx testing and fix non-root configuration
Browse files- nginx.conf +5 -3
- start.sh +17 -1
- test_nginx.sh +48 -0
nginx.conf
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
|
|
| 1 |
worker_processes 1;
|
| 2 |
-
error_log
|
| 3 |
pid /run/nginx/nginx.pid;
|
| 4 |
|
| 5 |
events {
|
|
@@ -32,13 +33,14 @@ http {
|
|
| 32 |
}
|
| 33 |
|
| 34 |
# Viewer route
|
| 35 |
-
location /viewer
|
| 36 |
-
proxy_pass http://viewer/viewer
|
| 37 |
proxy_http_version 1.1;
|
| 38 |
proxy_set_header Upgrade $http_upgrade;
|
| 39 |
proxy_set_header Connection "upgrade";
|
| 40 |
proxy_set_header Host $host;
|
| 41 |
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
| 42 |
}
|
| 43 |
}
|
| 44 |
}
|
|
|
|
| 1 |
+
# Note: user directive removed for non-root operation
|
| 2 |
worker_processes 1;
|
| 3 |
+
error_log stderr info;
|
| 4 |
pid /run/nginx/nginx.pid;
|
| 5 |
|
| 6 |
events {
|
|
|
|
| 33 |
}
|
| 34 |
|
| 35 |
# Viewer route
|
| 36 |
+
location /proxy/3939/viewer {
|
| 37 |
+
proxy_pass http://viewer/viewer;
|
| 38 |
proxy_http_version 1.1;
|
| 39 |
proxy_set_header Upgrade $http_upgrade;
|
| 40 |
proxy_set_header Connection "upgrade";
|
| 41 |
proxy_set_header Host $host;
|
| 42 |
proxy_set_header X-Real-IP $remote_addr;
|
| 43 |
+
proxy_read_timeout 86400;
|
| 44 |
}
|
| 45 |
}
|
| 46 |
}
|
start.sh
CHANGED
|
@@ -1,6 +1,22 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
nginx
|
| 5 |
|
| 6 |
# Start the application on port 7861 (Nginx will proxy from 7860)
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
+
# Run Nginx tests
|
| 4 |
+
echo "Running Nginx tests..."
|
| 5 |
+
if ! ./test_nginx.sh; then
|
| 6 |
+
echo "Nginx tests failed. Check permissions and configuration."
|
| 7 |
+
exit 1
|
| 8 |
+
fi
|
| 9 |
+
|
| 10 |
+
# Create required directories with correct permissions
|
| 11 |
+
mkdir -p /var/log/nginx
|
| 12 |
+
chmod 777 /var/log/nginx
|
| 13 |
+
touch /var/log/nginx/error.log
|
| 14 |
+
chmod 666 /var/log/nginx/error.log
|
| 15 |
+
touch /var/log/nginx/access.log
|
| 16 |
+
chmod 666 /var/log/nginx/access.log
|
| 17 |
+
|
| 18 |
+
# Start Nginx without user directive
|
| 19 |
+
sed -i 's/^user/#user/' /etc/nginx/nginx.conf
|
| 20 |
nginx
|
| 21 |
|
| 22 |
# Start the application on port 7861 (Nginx will proxy from 7860)
|
test_nginx.sh
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Function to log messages
|
| 4 |
+
log_msg() {
|
| 5 |
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
# Test Nginx directories and permissions
|
| 9 |
+
test_nginx() {
|
| 10 |
+
log_msg "Testing Nginx configuration..."
|
| 11 |
+
|
| 12 |
+
# Test directory existence and permissions
|
| 13 |
+
directories=(
|
| 14 |
+
"/var/log/nginx"
|
| 15 |
+
"/var/lib/nginx"
|
| 16 |
+
"/var/lib/nginx/body"
|
| 17 |
+
"/run/nginx"
|
| 18 |
+
"/etc/nginx"
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
for dir in "${directories[@]}"; do
|
| 22 |
+
if [ ! -d "$dir" ]; then
|
| 23 |
+
log_msg "ERROR: Directory $dir does not exist"
|
| 24 |
+
return 1
|
| 25 |
+
fi
|
| 26 |
+
|
| 27 |
+
# Test write permissions
|
| 28 |
+
if ! touch "$dir/test_file" 2>/dev/null; then
|
| 29 |
+
log_msg "ERROR: Cannot write to $dir"
|
| 30 |
+
return 1
|
| 31 |
+
fi
|
| 32 |
+
rm -f "$dir/test_file"
|
| 33 |
+
|
| 34 |
+
log_msg "OK: $dir exists and is writable"
|
| 35 |
+
done
|
| 36 |
+
|
| 37 |
+
# Test Nginx configuration
|
| 38 |
+
if ! nginx -t; then
|
| 39 |
+
log_msg "ERROR: Nginx configuration test failed"
|
| 40 |
+
return 1
|
| 41 |
+
fi
|
| 42 |
+
|
| 43 |
+
log_msg "Nginx configuration test passed"
|
| 44 |
+
return 0
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
# Run the test
|
| 48 |
+
test_nginx
|