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: if root is in Nix store, use path's hash as ETag #48337

Merged
merged 6 commits into from
Apr 18, 2019
Merged

nginx: if root is in Nix store, use path's hash as ETag #48337

merged 6 commits into from
Apr 18, 2019

Commits on Apr 18, 2019

  1. nginx: if root is in Nix store, use path's hash as ETag

    Resolves #25485. Usage example:
    
    $ realpath /var/www
    /nix/store/wnrhnnpdj3x50j5xz38zp1qxs1ygwccw-site
    $ curl --head localhost
    HTTP/1.1 200 OK
    Server: nginx
    Date: Fri, 28 Sep 2018 06:09:25 GMT
    Content-Type: text/html
    Content-Length: 50
    Last-Modified: Thu, 01 Jan 1970 00:00:01 GMT
    Connection: keep-alive
    ETag: "wnrhnnpdj3x50j5xz38zp1qxs1ygwccw"
    Accept-Ranges: bytes
    lukateras authored and aszlig committed Apr 18, 2019
    Configuration menu
    Copy the full SHA
    135d54f View commit details
    Browse the repository at this point in the history
  2. nginx: check for realpath() == NULL in ETag patch

    Thanks to Gabriel Ebner!
    lukateras authored and aszlig committed Apr 18, 2019
    Configuration menu
    Copy the full SHA
    f03302b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1da8eec View commit details
    Browse the repository at this point in the history
  4. nginx: Fix memleak in nix-etag patch

    The original patch introduced a new "real" variable which gets populated
    (and allocated) via ngx_realpath(). It's properly freed in error
    conditions but it won't be freed if ngx_http_set_etag returns
    successfully.
    
    Adding another ngx_free() just before returning fixes that memory leak.
    
    I also fixed a small indentation issue along the way.
    
    Signed-off-by: aszlig <aszlig@nix.build>
    aszlig committed Apr 18, 2019
    Configuration menu
    Copy the full SHA
    af5a3ce View commit details
    Browse the repository at this point in the history
  5. nixos/tests/nginx: Add subtest for Nix ETag patch

    This is to make sure that we get different ETag values whenever we
    switch to a different store path but with the same file contents.
    
    I've checked this against the old behaviour without the patch and it
    fails as expected.
    
    Signed-off-by: aszlig <aszlig@nix.build>
    aszlig committed Apr 18, 2019
    Configuration menu
    Copy the full SHA
    d533285 View commit details
    Browse the repository at this point in the history
  6. nginx/etag-patch: Use Nix store dir from build env

    So far, the Nix store directory was hardcoded and if someone uses a
    different Nix store directory the patch won't work. Of course, this is
    pretty uncommon, but by not only substituting the store directory but
    also the length of it we also save a few calls to ngx_strlen(), which
    should save us a few cycles.
    
    Signed-off-by: aszlig <aszlig@nix.build>
    aszlig committed Apr 18, 2019
    Configuration menu
    Copy the full SHA
    1f24685 View commit details
    Browse the repository at this point in the history