1
0
mirror of git://f0xx.org/android_cast synced 2026-07-29 03:38:52 +03:00

snap + backend headache

This commit is contained in:
Anton Afanasyeu
2026-05-21 17:15:18 +02:00
parent 8c5a0162a2
commit 2e04711c8f
35 changed files with 1328 additions and 88 deletions

View File

@@ -1,14 +1,16 @@
# Inner VM nginx — crash reporter behind apps.f0xx.org reverse proxy.
# Inner VM nginx — crash reporter behind reverse proxy.
#
# Files: .../androidcast_project/backend/public/ (symlink to examples/crash_reporter/backend/public)
# URL: https://apps.f0xx.org/app/androidcast_project/crashes/
# PHP: config.php → 'base_path' => '/app/androidcast_project/crashes'
# Adjust CRASH_PUBLIC to match your deploy (symlink OK):
# /var/www/localhost/htdocs/apps/app/androidcast_project/backend/public
#
# Outer proxy must pass the full URI and Host (your apps.f0xx.org block already does).
# URL prefix must match config.php base_path:
# /app/androidcast_project/crashes
# set this once if your install supports it, else replace paths below
# map is optional; explicit paths in each block are clearest
server {
listen 443 ssl;
# server_name _;
ssl_certificate "/etc/letsencrypt/archive/apps.f0xx.org/fullchain1.pem";
ssl_certificate_key "/etc/letsencrypt/archive/apps.f0xx.org/privkey1.pem";
@@ -16,32 +18,56 @@ server {
access_log /var/log/nginx/apps.intra.raptor.org.access_log main;
error_log /var/log/nginx/apps.intra.raptor.org.error_log warn;
# Do NOT set root to androidcast_project/ — that doubles the /app/androidcast_project/ prefix on disk.
# --- adjust only this directory root on disk ---
# CRASH_PUBLIC = .../backend/public
# --- Crash reporter (only this block handles the app) ---
location ^~ /app/androidcast_project/crashes/ {
alias /var/www/localhost/htdocs/apps/app/androidcast_project/backend/public/;
index index.php;
try_files $uri $uri/ @crash_php;
location ~ \.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/run/php-fpm.socket;
# $request_filename is correct when alias ends with / and location ends with /
fastcgi_param SCRIPT_FILENAME $request_filename;
client_max_body_size 4m;
}
location = /app/androidcast_project/crashes {
return 301 /app/androidcast_project/crashes/;
}
location @crash_php {
include /etc/nginx/fastcgi.conf;
# Directory URL -> index.php (avoids try_files + alias bugs)
location = /app/androidcast_project/crashes/ {
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm.socket;
fastcgi_param SCRIPT_FILENAME /var/www/localhost/htdocs/apps/app/androidcast_project/backend/public/index.php;
fastcgi_param SCRIPT_NAME /app/androidcast_project/crashes/index.php;
fastcgi_param REQUEST_URI $request_uri;
client_max_body_size 4m;
}
location = /app/androidcast_project/crashes/index.php {
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm.socket;
fastcgi_param SCRIPT_FILENAME /var/www/localhost/htdocs/apps/app/androidcast_project/backend/public/index.php;
fastcgi_param SCRIPT_NAME /app/androidcast_project/crashes/index.php;
fastcgi_param REQUEST_URI $request_uri;
client_max_body_size 4m;
}
location = /app/androidcast_project/crashes/api/upload.php {
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm.socket;
fastcgi_param SCRIPT_FILENAME /var/www/localhost/htdocs/apps/app/androidcast_project/backend/public/api/upload.php;
fastcgi_param SCRIPT_NAME /app/androidcast_project/crashes/api/upload.php;
fastcgi_param REQUEST_URI $request_uri;
client_max_body_size 4m;
}
# Static assets (css/js)
location ^~ /app/androidcast_project/crashes/assets/ {
alias /var/www/localhost/htdocs/apps/app/androidcast_project/backend/public/assets/;
}
# Any other .php under the prefix (if added later)
location ~ ^/app/androidcast_project/crashes/(.+\.php)$ {
alias /var/www/localhost/htdocs/apps/app/androidcast_project/backend/public/$1;
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm.socket;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param REQUEST_URI $request_uri;
client_max_body_size 4m;
}
# Optional: parent path → crashes (stops 400 probes on /app/androidcast_project/)
location = /app/androidcast_project {
return 301 /app/androidcast_project/crashes/;
}
@@ -49,14 +75,17 @@ server {
return 301 /app/androidcast_project/crashes/;
}
# Other PHP on this host (outside crash app)
location ~ \.php$ {
root /var/www/localhost/htdocs/apps/app/androidcast_project;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/run/php-fpm.socket;
}
location ~ /\. {
deny all;
}
}
# WHY "Primary script unknown":
# - include fastcgi.conf often sets SCRIPT_FILENAME=$document_root$fastcgi_script_name
# - That breaks under "alias" and subpath URLs -> php-fpm looks for a file that does not exist
# - Fix: use fastcgi_params + explicit SCRIPT_FILENAME absolute path (above)
#
# Verify on VM:
# ls -la /var/www/.../backend/public/index.php
# ls -la /var/www/.../backend/public/api/upload.php
# sudo -u nginx test -r .../index.php # user = php-fpm pool user