mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-07 20:14:24 +08:00
Add support for virtual-hosted style bucket URLs
@@ -1,4 +1,6 @@
|
||||
It's a common concept to put a proxy in front of S3 that handles requests. Nginx is well suited for this and can be used to additionally handle TLS and path style (using subdomains instead of subfolders).
|
||||
It's a common concept to put a proxy in front of S3 that handles requests. Nginx is well suited for this and can be used to handle TLS and virtual-hosted style bucket URLs (using subdomains instead of subfolders).
|
||||
|
||||
For virtual-hosted style URL buckets, you'll need to add a [wildcard DNS record](https://en.wikipedia.org/wiki/Wildcard_DNS_record) for your S3 subdomain.
|
||||
|
||||
### Example Nginx config
|
||||
|
||||
@@ -10,24 +12,35 @@ upstream seaweedfs { server localhost:8333 fail_timeout=0; keepalive 20;}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name ~^(?<subdomain>[^.]+).yourdomain.com;
|
||||
|
||||
# Assumes that your subdomain is s3
|
||||
# The regex will support path style as well as virtual-hosted style bucket URLs
|
||||
# path style: http://s3.yourdomain.com/mybucket
|
||||
# virtual-hosted style: http://mybucket.s3.yourdomain.com
|
||||
server_name ~^(?:(?<bucket>[^.]+)\.)s3\.yourdomain\.com;
|
||||
|
||||
ignore_invalid_headers off;
|
||||
client_max_body_size 0;
|
||||
proxy_buffering off;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
proxy_connect_timeout 300;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
chunked_transfer_encoding off;
|
||||
|
||||
# If bucket subdomain is not empty,
|
||||
# rewrite request to backend.
|
||||
if ($bucket != "") {
|
||||
rewrite (.*) /$bucket$1 last;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
proxy_connect_timeout 300;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
chunked_transfer_encoding off;
|
||||
|
||||
proxy_pass http://seaweedfs$request_uri;
|
||||
proxy_pass http://seaweedfs;
|
||||
}
|
||||
|
||||
ssl on;
|
||||
|
Reference in New Issue
Block a user