From eff95ad8a6e7ec73094eaed85ae7861b67741ff1 Mon Sep 17 00:00:00 2001 From: Oscar Admin Contributors Date: Thu, 3 Dec 2026 18:42:18 -0500 Subject: [PATCH] Add nginx subdomain and subpath examples --- README.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d786147..524e3c2 100755 --- a/README.md +++ b/README.md @@ -104,20 +104,66 @@ Do not serve or commit: - `audit.log` - admin action log - `gotify-users.php` - per-user Gotify tokens/URLs -Example nginx rules (adjust paths to your install): +Serve over HTTPS and consider an IP allowlist/VPN/auth proxy. The examples below include sensitive-file denies; adjust paths, PHP-FPM socket, and TLS settings for your system. + +#### Nginx example: subdomain + +Use this when Oscar Admin is the document root for a dedicated host like `admin.example.com`: ```nginx -location /admin/ { - # ... php handling ... +server { + listen 443 ssl http2; + server_name admin.example.com; - location ~* /admin/(config\.php|config\.example\.php|lib\.php|lib_gotify\.php|user-menu\.php|gotify-users\.php|gotify-users\.json|audit\.log|README\.md|\.gitignore)$ { + root /var/www/oscar-admin; + index index.php; + + # TLS config omitted for brevity + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + # Deny sensitive/internal files + location ~* ^/(config\.php|config\.example\.php|lib\.php|lib_gotify\.php|user-menu\.php|gotify-users\.php|gotify-users\.json|audit\.log|README\.md|SECURITY\.md|CONTRIBUTING\.md|AI_DISCLOSURE\.md|LICENSE|\.gitignore|\.htaccess)$ { deny all; return 404; } + + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_pass unix:/run/php/php8.2-fpm.sock; + } } ``` -Also serve the admin panel over HTTPS and consider an IP allowlist/VPN/auth proxy. +#### Nginx example: subpath + +Use this when serving Oscar Admin under a path like `https://example.com/admin/`: + +```nginx +location = /admin { + return 301 /admin/; +} + +location /admin/ { + alias /var/www/oscar-admin/; + index index.php; + + # Deny sensitive/internal files + location ~* ^/admin/(config\.php|config\.example\.php|lib\.php|lib_gotify\.php|user-menu\.php|gotify-users\.php|gotify-users\.json|audit\.log|README\.md|SECURITY\.md|CONTRIBUTING\.md|AI_DISCLOSURE\.md|LICENSE|\.gitignore|\.htaccess)$ { + deny all; + return 404; + } + + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_pass unix:/run/php/php8.2-fpm.sock; + } +} +``` ## Project Structure