Skip to content
This repository has been archived by the owner on Mar 25, 2022. It is now read-only.

Commit

Permalink
gateway: add /refs/*
Browse files Browse the repository at this point in the history
Rewrites requests for /refs/a/b/c to c.b.a.refs.ipfs.io.

Also replaces conditionals with location directives,
which are evaluated more efficiently.

License: MIT
Signed-off-by: Lars Gierth <[email protected]>
  • Loading branch information
Lars Gierth committed Oct 3, 2015
1 parent a1069e1 commit 4734f08
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions solarnet/roles/ipfs_gateway/templates/nginx_ipfs_gateway.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,22 @@ server {

resolver 8.8.8.8 8.8.4.4;

set $hosturi $host$uri;
set $proxyhost "";
if ($hosturi !~ "^(h\.)?ipfs\.io/(ipfs|ipns|api)(/|$)") {
set $proxyhost $host;
location /refs/ {
rewrite "^/refs/([^/]+)/([^/]+)/([^/]+)$" "/" break;
proxy_set_header Host $3.$2.$1.refs.ipfs.io;
proxy_pass http://gateway;
proxy_read_timeout 1800s;
}

location ~ "^/(ipfs|ipns|api)(/|$)" {
proxy_set_header Host "";
proxy_pass http://gateway;
proxy_read_timeout 1800s;
}

location / {
proxy_set_header Host $host;
proxy_pass http://gateway;
proxy_set_header Host $proxyhost;
proxy_read_timeout 1800s;
}

Expand Down

0 comments on commit 4734f08

Please sign in to comment.