From 69173356cd3e1862dbfd5072120e69ec48a11640 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Wed, 4 Jan 2017 18:06:14 +0100 Subject: [PATCH] API+Docker: enable nginx URL rewriting Closes https://github.com/shaarli/Shaarli/issues/668 Changed: - let nginx rewrite API URLs See: - https://www.slimframework.com/docs/start/web-servers.html - https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_split_path_info Signed-off-by: VirtualTam --- docker/development/nginx.conf | 9 +++++++++ docker/production/nginx.conf | 9 +++++++++ docker/production/stable/nginx.conf | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/docker/development/nginx.conf b/docker/development/nginx.conf index ac0c6c61..79c45bfe 100644 --- a/docker/development/nginx.conf +++ b/docker/development/nginx.conf @@ -56,7 +56,16 @@ http { alias /var/www/shaarli/images/favicon.ico; } + location / { + # Slim - rewrite URLs + try_files $uri /index.php$is_args$args; + } + location ~ (index)\.php$ { + # Slim - split URL path into (script_filename, path_info) + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + # filter and proxy PHP requests to PHP-FPM fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; diff --git a/docker/production/nginx.conf b/docker/production/nginx.conf index 5ffa02d0..e8754d9b 100644 --- a/docker/production/nginx.conf +++ b/docker/production/nginx.conf @@ -48,7 +48,16 @@ http { alias /var/www/shaarli/images/favicon.ico; } + location / { + # Slim - rewrite URLs + try_files $uri /index.php$is_args$args; + } + location ~ (index)\.php$ { + # Slim - split URL path into (script_filename, path_info) + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + # filter and proxy PHP requests to PHP-FPM fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; diff --git a/docker/production/stable/nginx.conf b/docker/production/stable/nginx.conf index 5ffa02d0..e8754d9b 100644 --- a/docker/production/stable/nginx.conf +++ b/docker/production/stable/nginx.conf @@ -48,7 +48,16 @@ http { alias /var/www/shaarli/images/favicon.ico; } + location / { + # Slim - rewrite URLs + try_files $uri /index.php$is_args$args; + } + location ~ (index)\.php$ { + # Slim - split URL path into (script_filename, path_info) + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + # filter and proxy PHP requests to PHP-FPM fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; -- 2.41.0