Add nginx subdomain and subpath examples

This commit is contained in:
Oscar Admin Contributors 2026-12-03 18:42:18 -05:00
parent fb11868aa9
commit eff95ad8a6

View file

@ -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