Static website: index.html does not open in browser, instead it downloads

Trying to use storj to host static website.

  1. I used uplink to create a share:
    uplink share --dns www.my_web_address.com sj://my_bucket_name/ --base-url https://link.storjshare.io

  2. I updated my dns settings:
    |my_web_address.com |IN|CNAME|link.storjshare.io.|
    |—|—|—|—|
    |txt-www.my_web_address.com|IN|TXT |storj-root:my_bucket_name|
    |txt-www.my_web_address.com|IN|TXT |storj-access:jw4zfxb5q2zs4e3uinc6sestwxaq|

Problem: When I navigate to www.my_web_address.com, the index.html file is not displayed - it only downloads the file.

Any thoughts anyone?

Hello @Brian1,
Welcome to the forum!

If you rename it to index.htm does it change anything?

I’ve changed it to index.htm and I now get this message:
Oops! Object not found.
…and it no longer downloads

Was the file uploaded using uplink or S3 gateway?

If you try curl [youraddress]/index.html -vvv what response headers are showing for you? I am interested if Content-Type was set incorrectly, which is one reason the browser will not recognise it as HTML and download the file instead.

This is probably not the cause but your CNAME record should include “www” also:

www.my_web_address.com. 3600 IN CNAME link.storjshare.io.

I am having this problem too.
The file was uploaded using uplink
The content type returned is “application/octet-stream”

*   Trying  redacted-IPV6-address ..
* Connected to redacted port 80 (#0)
> GET /index.html HTTP/1.1
> Host: redacted
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Access-Control-Allow-Headers: *
< Access-Control-Allow-Methods: GET, HEAD
< Access-Control-Allow-Origin: *
< Cache-Control:
< Content-Length: 142
< Content-Type: application/octet-stream
< Date: Wed, 21 Sep 2022 19:27:49 GMT
< Last-Modified: Thu, 24 Feb 2022 00:33:43 GMT
<
<!doctype html>
<html>
  <head>
    <title>Welcome!</title>
  </head>
  <body>
    <p>Hello <strong>world !!!</strong>.</p>
  </body>
</html>

Could you show the output of uplink meta get sj://path/to/file/index.html?

It seems like linksharing might not be detecting the right content type. It tries to auto-detect based on the extension. If Content-Type is set in metadata (or content-type in lowercase put by S3 clients), it will use that instead of guessing.

We have a fix on the way around these content types to auto-detect, but one way to ensure the file gets the right type is to set --metadata '{"Content-Type":"text/html"} when uploading the file with uplink.

If using S3, you can set content type on an existing file by aws s3 cp with the same source and destination, e.g. aws s3 cp s3://path/to/file s3://path/to/file --content-type text/html. The same flag can be used when uploading a new file as well.

Well, maybe i was wrong and didn’t originally upload the file with uplink (it was some time ago), but back then it was working fine.

The metadata it had was:

{
  "content-type": "application/octet-stream",
  "s3:etag": "9c9fdecbe6f81ac1c805f09edffe712f"
}

Now I reuploaded the file with uplink, and it works correctly ( with an empty set as metadata )

Thank you.

3 Likes

Then I can guess that you have used the Objects browser in the satellite UI.