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

Confirm if documented nginx proxy config works for row pages with escaped characters in their primary key #1578

Open
simonw opened this issue Dec 23, 2021 · 4 comments

Comments

@simonw
Copy link
Owner

simonw commented Dec 23, 2021

Found this while working on https://github.com/simonw/datasette-tiddlywiki

image

Then clicking on /tiddlywiki/tiddlers/%24%3A%2FDefaultTiddlers returns a 404.

@simonw simonw added the bug label Dec 23, 2021
@simonw
Copy link
Owner Author

simonw commented Dec 23, 2021

This problem doesn't occur on my localhost running Uvicorn directly - but I'm seeing it in my production environment that runs Datasette behind an nginx proxy:

    location / {
        proxy_pass http://127.0.0.1:8000/;
	proxy_set_header Host $host;
    }

@simonw simonw changed the title Primary key of $:/DefaultTiddlers results in 404 on row page Primary key of $:/DefaultTiddlers results in 404 on row page (behind nginx proxy) Dec 23, 2021
@simonw
Copy link
Owner Author

simonw commented Dec 23, 2021

This StackOverflow answer suggests that the fix is to change this:

proxy_pass http://127.0.0.1:8000/;

To this:

proxy_pass http://127.0.0.1:8000;

Quoting the nginx documentation: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

A request URI is passed to the server as follows:

  • If the proxy_pass directive is specified with a URI, then when a request is passed to the server, the part of a normalized request URI matching the location is replaced by a URI specified in the directive:

    location /name/ {
        proxy_pass http://127.0.0.1/remote/;
    }
    
  • If proxy_pass is specified without a URI, the request URI is passed to the server in the same form as sent by a client when the original request is processed, or the full normalized request URI is passed when processing the changed URI:

    location /some/path/ {
        proxy_pass http://127.0.0.1;
    }
    

@simonw
Copy link
Owner Author

simonw commented Dec 23, 2021

Confirmed, that fixed the bug for me on my server.

@simonw
Copy link
Owner Author

simonw commented Dec 23, 2021

The example nginx config on https://docs.datasette.io/en/stable/deploying.html#nginx-proxy-configuration is currently:

daemon off;

events {
  worker_connections  1024;
}
http {
  server {
    listen 80;
    location /my-datasette {
      proxy_pass http://127.0.0.1:8009/my-datasette;
      proxy_set_header Host $host;
    }
  }
}

This looks to me like it might exhibit the bug. Need to confirm that and figure out an alternative.

@simonw simonw changed the title Primary key of $:/DefaultTiddlers results in 404 on row page (behind nginx proxy) Confirm if documented nginx proxy config works for row pages with escaped characters in the primry key Dec 23, 2021
@simonw simonw changed the title Confirm if documented nginx proxy config works for row pages with escaped characters in the primry key Confirm if documented nginx proxy config works for row pages with escaped characters in their primary key Dec 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant