Skip to content

Instantly share code, notes, and snippets.

@boesing
Last active September 26, 2024 17:50
Show Gist options
  • Save boesing/7c16294244aa03def02f to your computer and use it in GitHub Desktop.
Save boesing/7c16294244aa03def02f to your computer and use it in GitHub Desktop.
NGINX OXID configuration
server {
listen 8080;
server_name localhost;
root /var/www/source;
autoindex off;
charset off;
add_header 'X-Content-Type-Options' 'nosniff' always;
add_header 'X-XSS-Protection' '1; mode=block' always;
set $script_name $fastcgi_script_name;
location /update {
return 404;
}
# Static files we want to serve from NGINX directly
location ~ ^/(export|out) {
try_files /dev/null @static-files;
}
# Always prepend slash to URLs without Slashes at the end
location ~ ^([^.?]*[^/])$ {
rewrite ^([^.]*[^/])$ $1/ redirect;
}
# Handle oxseo.php with mod_rewrite_module_is=off in query string
location = /oxseo.php {
set $script_name '/oxseo.php';
try_files /dev/null @php;
}
location = /admin/ {
set $script_name '/admin/index.php';
try_files /dev/null @php;
}
location ~ ^/admin/(index|oxajax).php$ {
try_files /dev/null @php;
}
# Redirect certain file types and directories to another handler (e.g., getimg.php)
location ~* ^/out/pictures/generated/.*\.(jpg|jpeg|gif|png|webp|svg)$ {
try_files $uri @generate-image;
}
location @generate-image {
internal;
set $script_name '/getimg.php';
try_files /dev/null @php;
}
# Handle GraphQL requests
location ~* ^/graphql/?$ {
rewrite ^ /widget.php?cl=graphql&skipSession=1 last;
}
location ~ /(index|widget|getimg|oxseo)\.php$ {
try_files /dev/null @php;
}
location / {
set $script_name '/oxseo.php';
try_files /dev/null @php;
}
location @static-files {
internal;
try_files $uri =404;
}
# Forward certain PHP files to php-fpm
location @php {
internal;
include fastcgi_params;
fastcgi_pass php-fpm;
fastcgi_intercept_errors on;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $realpath_root$script_name;
fastcgi_param SCRIPT_NAME $script_name;
}
}
upstream php-fpm {
server php:9000;
}
@boesing
Copy link
Author

boesing commented Sep 26, 2024

Only static files are served via NGINX, PHP requests are directly passed to the PHP-FPM upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment