# Virtual-hosted addressing

Every route is also served with the bucket in the host name, on S3's us-east-1 and global hostnames, which the CLI's gateway can route to the simulator.

Virtual-hosted addressing puts the bucket in the host name, as `<bucket>.s3.us-east-1.amazonaws.com` or `<bucket>.s3.amazonaws.com`, where path-style puts it first in the path. The simulator serves every route both ways: a request whose `Host` names one of those hosts is the path-style request with that bucket first in the path. Reach a local simulator by naming the host yourself:

```bash
s3curl() { curl -s --aws-sigv4 'aws:amz:us-east-1:s3' --user 'AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' "$@"; }
s3curl -H 'Host: acme-demo-site.s3.us-east-1.amazonaws.com' "$RYSTIC_URL/robots.txt"
# -> User-agent: *
# -> Allow: /
s3curl -H 'Host: acme-demo-site.s3.amazonaws.com' "$RYSTIC_URL/?list-type=2&prefix=about/" | grep -oE '<Key>[^<]*'
# -> <Key>about/index.html
```

### Keep S3's own hostnames

An SDK that is not given an endpoint override sends virtual-hosted requests to S3's hostnames, and the CLI's HTTPS gateway can route two of them to the simulator:

1. Boot the simulator behind the gateway with `rystic run s3-twin -d --port 0 --intercept --scenario s3_static_site`.
2. Run your client under `rystic exec -- <command>`, or `eval "$(rystic env)"` for a shell. The gateway routes the calls of clients that honor its proxy and CA settings to the simulator.

Of S3's hosts, the gateway routes only `s3.amazonaws.com` and `s3.us-east-1.amazonaws.com` to the simulator. A request to any other S3 region's host tunnels through to real AWS. Give that client an endpoint override, or add `--strict` to `rystic exec` or `rystic env` so the gateway refuses every host no simulator claims.

For example, this command reads the site's `robots.txt` from the simulator: `rystic exec -- curl -s --aws-sigv4 'aws:amz:us-east-1:s3' --user 'AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' https://acme-demo-site.s3.us-east-1.amazonaws.com/robots.txt`.

A client that keeps its own certificate store needs the gateway's CA configured. Path-style on an endpoint override needs nothing, and is the form to use when you control the client.

### What is not compared with S3

Virtual-hosted addressing is unconfirmed, meaning not yet compared with S3. The simulator's own tests cover it, but no request to S3 can set its `Host`.

---

Source: https://www.rystic.ai/docs/simulators/s3/features/virtual-hosted-addressing · Markdown: https://www.rystic.ai/docs/simulators/s3/features/virtual-hosted-addressing.md
