IdentityPython / pyFF

SAML metadata aggregator
https://pyff.io/
Other
50 stars 36 forks source link

[Documentation] Serve Metadata as static content with NGINX #172

Closed peppelinux closed 5 years ago

peppelinux commented 5 years ago

I'm using NginX to serve metadata on MDQ queryes like:

# get all the entitities in a single aggregated metadata
/entities

# get a single metadata, related to the hashed entityID in the request URL
# the encoded value is a hashed entity_id
/entities/{sha1}baf9ddc66fa9d6a6077e72cd04e0e292ccbc7676

The rules are the following

   location ~ /entities/\{sha1\}(.*) {
      default_type "application/xml; charset=utf-8";
      alias /opt/pyff/md/$1.xml;
   }

    location ~ /entities$ {
       default_type "application/xml; charset=utf-8";
       alias /opt/pyff/md/md-loaded.xml;
    }

This experience is related to https://github.com/IdentityPython/pyFF/pull/171

pyff without a CACHE will take roughly 3 or 4 seconds to get back the result, NginX instead will take 36ms. In addition to this if nginx is unable to find the requested sha1 metadata it will return 404, instead of error 500 as pyff does.

Please share your ideas

leifj commented 5 years ago

look at scripts/mirror-mdq.sh and also test the new api backend. With the redis backend and config.cache_size turned up to a bit more than your expected volume of entities you should get much better performance.

peppelinux commented 5 years ago

At the moment I'll be in production with nginx static serve, when I'll have more time I'll try to read the code and understand your suggestions, otherwise I'll wait more time to get for official documentation on these tasks. thank you @leifj