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

nginx should handle HTTP 403 to the backend, too #5

Open
franzenzenhofer opened this issue Apr 3, 2011 · 3 comments
Open

nginx should handle HTTP 403 to the backend, too #5

franzenzenhofer opened this issue Apr 3, 2011 · 3 comments

Comments

@franzenzenhofer
Copy link

/etc/nginx/sites-available/myapp-httpp

currently is:

location / {
root        /var/myapp/public;
index       index.html;
error_page  404 = @backend;
}

should:

location / {
root        /var/myapp/public;
index       index.html;
error_page  404 = @backend;
error_page  403 = @backend;
}

otherwise it is not possible return something from node.js on the root (i.e.: http://www.myapp.com/) of the domain, as nginx (if the 'public' folder exists) needs to handle an HTTP 403 instead of an HTTP 404.

@rsms
Copy link
Owner

rsms commented Apr 3, 2011

Does this allow an /index.html to be served if there's one? That is, both of the following use-cases are true/successful:

Use-case 1:

  1. There's no index.html in the public (web root) directory
  2. A request for "/" asks @backend to handle the request

Use-case 2:

  1. There is a index.html in the public (web root) directory
  2. A request for "/" returns the index.html (from the public (web root) directory)

AFAIK "redirecting" 403 to the backend would break serving of /index.html, but I haven't confirmed this.

@franzenzenhofer
Copy link
Author

with the
error_page 403 = @backend;
fix

use case 1: if there is no index.html a request for / will be handled to the @backend
use case 2: if there is a index.html a request for / will return the index.html in the public folder.

so this fix should fullfill both use cases.

@atestu
Copy link

atestu commented Aug 11, 2011

I still get a 502 Bad Gateway error with this fix. What am I doing wrong? I'm running socket.io and expressjs, FYI.
Thanks for your time, this is starting to drive me insane.

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

3 participants