Hosting your own OpenID with Nginx, SimpleID and Yadis


Just updated my OpenID hosting on to make it that little bit smoother. In the past I had been using the MyPhpId script to do this, I recently switched to SimpleID for no other reason than to try it out. I also wanted to clean up the delegation stuff.

Installing SimpleID is easy. Follow the installation step ensuring the correct directory locations and cache permissions. Setup your identity using ‘sreg’ extensions if you want too.

Usually to setup your delegation for OpenID you need to include two headers in your html page like this:

<link rel="openid.server" ref="" />
<link rel="openid.delegate" ref="" />

The first link is where the openid server is located. Naturally this is my own. The second link is what I want my OpenID URL to be and what the server knows me as. This is the URL used in my identity file.

While this is fine, it can do with some improvements. Firstly, it is recommended to seperate the OpenID v1 and v2 links so my links then look like this:

<link rel="openid2.provider" href="" />
<link rel="openid2.local_id" href="" />
<link rel="openid.server" href="" />
<link rel="openid.delegate" href="" />

This can also be improved. This means that to find the delegate information a client has to download the entire page just for this small amount of information. Yadis is a service discovery system to allow easy discovery of the protocol used. Primarily used for single sign on such as OpenID. So here we can provide a Yadis file to speed up the authentication process.

It is quite simple to convert the link based system above into a static Yadis file that can be served up to clients wanting the delegate information. My Yadis file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">
        <Service priority="10">
        <Service priority="20" xmlns:openid="">

This file needs to be served as an ‘application/xrds+xml’ mime type. Now any client wanting this information will have an accept header set accordingly so with a simple rewrite in my Nginx config file I can serve this information quickly.

if ($http_accept ~* application/xrds\+xml) {
  rewrite ^ /yadis.xrdf break;