Skip to content

Instantly share code, notes, and snippets.

@bdwyertech
Created December 10, 2015 22:46
Show Gist options
  • Save bdwyertech/d5b1e097ea158a232aa3 to your computer and use it in GitHub Desktop.
Save bdwyertech/d5b1e097ea158a232aa3 to your computer and use it in GitHub Desktop.
Nginx - Nested locations and PHP-FPM
# => YOURLS URL Shortener Configuration
location /u/ {
root /var/www/api/urls/;
rewrite ^/(.*)/$ /$1/index.php last; # Enables index functionality (only really used for /u/admin/)
rewrite ^/u/(.*)$ /$1 break; # Strips /u/ from the URI for static files
try_files $uri /u/yourls-loader.php$is_args$args;
# => API PHP-FPM
location ~ \.php$ {
fastcgi_split_path_info ^/u(.+?\.php)(.*)$;
try_files $fastcgi_script_name =404;
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param PATH_INFO $fastcgi_path_info;
#fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass unix:/var/run/pipeline.sock; # port where FastCGI processes were spawned
}
}
@H-s-O
Copy link

H-s-O commented Aug 20, 2019

Oh boy, this saved my sanity after hours of pulling my hair off. What a clusterfuck nested locations are.

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