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

Issue while Serving from Nginx #25

Closed
kartikv11 opened this issue May 27, 2016 · 2 comments
Closed

Issue while Serving from Nginx #25

kartikv11 opened this issue May 27, 2016 · 2 comments

Comments

@kartikv11
Copy link

kartikv11 commented May 27, 2016

Firstly, Thanks for a great blueprint to start with.
I have deployed our Ember App using Lightning Deploy Strategy which involves:

EC2 instance

  • Nginx (HTTP Server)
  • Redis, configured on same instance (to serve index.html)
  • compiled js and assets from AWS S3
  • When, upon hitting the instance, the index.html gets served from Redis, and subsequently on clicking any route in the App, the App routes get served cos it knows which js to execute.

But, when I manually enter any correct route in URL for the Ember App and to a Hard Reload, Nginx throws an error saying route not found. Anything wrong that we are doing here regarding this deploy strategy?

Also posted this on Stackoverflow: Link

@AjeetK
Copy link

AjeetK commented Jun 12, 2016

When a subrequest, say, mydomain.com/login is hit with the url or the page is refreshed, the browser sends a requests to nginx and nginx won't be able to find the login page anywhere and will return a 404 error. This is because nginx won't be able to pass the subroutes to index.html page which in turn can serve the subroutes. To solve this the following location block is used in nginx.

  # This block handles the subrequest. If any subroutes are requested than this rewrite the url to root and tries to render the subroute page by passing the subroute to index file (which is served by the redis).
  location ~* / {
  rewrite ^ / last;
  }

Here we are saying to nginx, for any subrequests, rewrite the url to root (/) location (root location serves the index page from redis) and find the requested page. The last option tries to find the particular page by revisiting all the blocks defined in nginx as a result of which it is able to go to root location.
A detailed explanation and full nginx config can be found here.

@kartikv11
Copy link
Author

Thanks, this issue can be closed. +1

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