Open domenicomazza opened 8 years ago
I think this is all you need:
location / {
# Stacey Rules
error_page 404 /404.html;
# Rewrite any calls to /render to the image parser
rewrite ^/render/. /app/parsers/slir/ break;
# Rewrite any file calls to the public directory
try_files $uri $uri/ /index.php?$uri /public$uri;
}
Inside a server{}
block. I took it from here:
https://github.com/afonsoduarte/ansible-stacey/blob/master/roles/nginx/templates/stacey.conf.j2
Cheers @afonsoduarte I looked high and low for working examples, and there it was!
It's working for the root directory and loading images, but clicking on any page links produces a 500 error. The Nginx error log states rewrite or internal redirection cycle while internally redirecting to "/public/public/public/public/public/public/pu$
I'm suspicious of try_files
. I'll play around with it. If I come up with a solution, I'll post it here.
Ok. I got the configuration working by removing /public$uri
which was causing the loops. Anywhere where I've used the shorthand {{ page.root_path }}/docs
in Stacey has been changed to explicitly go to /public, thus {{ page.root_path }}/public/docs
.
server {
root SERVER FILE LOCATION;
index index.php index.html index.htm;
# Make site accessible from
server_name YOUR IP OR DOMAIN NAME;
location / {
# Stacey Rules
error_page 404 /404.html;
# Rewrite any calls to /render to the image parser
rewrite ^/render/. /app/parsers/slir/ break;
# Rewrite any file calls to the public directory
try_files $uri $uri/ /index.php?$uri;
}
# Block access to .htaccess files
location ~ /\.ht {
deny all;
}
include /usr/local/nginx/conf/staticfiles.conf;
include /usr/local/nginx/conf/php.conf;
}
Note: the include
files are just standard error page links and PHP (Fast-cgi php-fpm) config I've put together to save repeating the same thing across multiple site setups.
Has anyone installed a Stacey site on an Nginx server? If you have a working config file it would certainly be worth contributing. .htaccess to Nginx config converters aren't great nor are my regex/mod-rewrite/Nginx skills, otherwise I'd contribute.