ruby on rails - Nginx Unicorn AngularJS html5 URLs configuration -
i want add pretty urls in angular ui-router. have nginx + unicorn on rails app angular js front-end.
i want have pretty urls mysite/a/b/c, no '#' , no hashbang. when change location of nginx to:
server { server_name yoursite.com; root /path/to/app; location / { try_files $uri $uri/ @unicorn; } }
unicorn throw error:
directory index of "/path/to/app" forbidden
any idea on how setup nginx redirect? giving chmod app path isn't solution believe..
edit: issue try_files $uri/index @unicorn, works e.g. url.com/a/b. when refresh, automatically redirects me root url.com. ui-router suggests try_files $uri $uri/ /index.html, when access denied nginx. folder /path/to/app belongs user 'deploy', it's not chmod issue..
finally solved it! mistake, because running app angular forgot in rails routes.rb file line:
get '*path' => '/'
changed
get '*path' => 'layouts#index'
where layouts#index layout angular, , after refreshing url.com/a/b url stays url.com/a/b , renders appropriate route.
at nginx config remained:
location /{ try_files $uri @unicorn; }
Comments
Post a Comment