Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stacey Config for Nginx #143

Open
domenicomazza opened this issue Nov 15, 2015 · 3 comments
Open

Stacey Config for Nginx #143

domenicomazza opened this issue Nov 15, 2015 · 3 comments

Comments

@domenicomazza
Copy link

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.

@afonsoduarte
Copy link

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

@domenicomazza
Copy link
Author

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.

@domenicomazza
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants