Support hns subdomains (#420)
* support hns subdomains * document feature
This commit is contained in:
parent
5c557d96c2
commit
3469943a0b
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
|
||||
(siasky.net) {
|
||||
siasky.net, *.siasky.net {
|
||||
siasky.net, *.siasky.net, *.hns.siasky.net {
|
||||
tls {
|
||||
dns route53
|
||||
}
|
||||
|
|
|
@ -22,9 +22,8 @@ server {
|
|||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
# parse subdomain (a base32 encoded Skylink) into custom variable
|
||||
server_name "~^([a-z0-9]{55})\..*$";
|
||||
set $subdomain $1;
|
||||
# understand the regex https://regex101.com/r/BGQvi6/2/
|
||||
server_name "~^(((?<base32_subdomain>([a-z0-9]{55}))|(?<hns_domain>[^\.]+)\.hns)\.)?(?<domain>[^.]+)\.(?<tld>[^.]+)$";
|
||||
|
||||
# ddos protection: closing slow connections
|
||||
client_body_timeout 5s;
|
||||
|
@ -36,17 +35,22 @@ server {
|
|||
client_max_body_size 128k;
|
||||
|
||||
location / {
|
||||
# The only safe thing to do inside an if in a location block is return
|
||||
# or rewrite, since we need to proxy_pass we have to work our way around
|
||||
# using a custom error code.
|
||||
#
|
||||
# This is only safe workaround to reroute based on some conditions
|
||||
# See https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/
|
||||
error_page 418 = @subdomain;
|
||||
recursive_error_pages on;
|
||||
if ($subdomain != "") {
|
||||
|
||||
# redirect links with base32 encoded skylink in subdomain
|
||||
error_page 418 = @base32_subdomain;
|
||||
if ($base32_subdomain != "") {
|
||||
return 418;
|
||||
}
|
||||
|
||||
# redirect links with handshake domain on hns subdomain
|
||||
error_page 419 = @hns_domain;
|
||||
if ($hns_domain != "") {
|
||||
return 419;
|
||||
}
|
||||
|
||||
include /etc/nginx/conf.d/include/cors;
|
||||
|
||||
root /var/www/webportal;
|
||||
|
@ -233,10 +237,16 @@ server {
|
|||
proxy_pass http://siad/skynet/skylink/$skylink$is_args$args;
|
||||
}
|
||||
|
||||
location @subdomain {
|
||||
location @base32_subdomain {
|
||||
include /etc/nginx/conf.d/include/proxy-buffer;
|
||||
|
||||
proxy_pass http://127.0.0.1/$subdomain/$request_uri;
|
||||
proxy_pass http://127.0.0.1/$base32_subdomain/$request_uri;
|
||||
}
|
||||
|
||||
location @hns_domain {
|
||||
include /etc/nginx/conf.d/include/proxy-buffer;
|
||||
|
||||
proxy_pass http://127.0.0.1/hns/$hns_domain/$request_uri;
|
||||
}
|
||||
|
||||
location ~ "^/file/([a-zA-Z0-9-_]{46}(/.*)?)$" {
|
||||
|
|
Reference in New Issue