Index of IPFS file explorer not considering subdomain

Hello,

I have noticed a strange behavior from the IPFS file explorer, the linked CID after “Index of /ipfs/” redirects to the root of the domain on which the gateway from where you access the files is running.

To what I’ve been testing, it seems to only do that on subdomain gateways though.

Meaning that, in the example below and in my personnal case also, if you are accessing files from a subdomain gateway running under “ipfs.example.com” the link will be “example.com/ipfs/CID”. So it ignores both the subdomain under which the gateway is running & the origin isolation of the subdomain gateway.

In my case it is pretty problematic as I have a website running on “example.com”, thus when we click on the link suggested by the file explorer it sends the user to my website & facing a beautiful 404.

The other issue in my case is that my gateway is not running on the same server as my website, making the matter even worse. I have tried setting up the nginx server on my website’s VPS to rewrite the URL to add “ipfs.” before “example.com” but for some reasons it instead sends to ipfs.io 's gateway.

If anyone knows why it behaves like that I’d love to know.

I don’t think it does that in general, it’s just that “ipfs” and “ipns” are reserved subdomains. Use something else, and it will probably work.

Thanks for the reply, it was the exact source of the issue.

Either host it on example.com or a different subdomain than ipfs or ipns.

Don’t forget to also configure your SSL cert to include *.ipfs.smth.example.com and *.ipns.smth.example.com, else it will throw antivirus warnings for some users.

My AV for instance doesn’t like subdomains ran on wildcard certificates more than 1 subdomain away from where the wildcard cert was emitted. Meaning that if my cert is on *.example.com; smth.example.com will be fine, but ipfs.smth.example.com will throw a warning.