mirror of
https://github.com/sadoyan/aralez.git
synced 2026-04-30 23:08:40 +08:00
http to https redirect cleanup
This commit is contained in:
15
README.md
15
README.md
@@ -125,14 +125,13 @@ A sample `upstreams.yaml` entry:
|
|||||||
provider: "file"
|
provider: "file"
|
||||||
sticky_sessions: false
|
sticky_sessions: false
|
||||||
to_ssl: false
|
to_ssl: false
|
||||||
globals:
|
headers:
|
||||||
headers:
|
- "Access-Control-Allow-Origin:*"
|
||||||
- "Access-Control-Allow-Origin:*"
|
- "Access-Control-Allow-Methods:POST, GET, OPTIONS"
|
||||||
- "Access-Control-Allow-Methods:POST, GET, OPTIONS"
|
- "Access-Control-Max-Age:86400"
|
||||||
- "Access-Control-Max-Age:86400"
|
authorization:
|
||||||
authorization:
|
type: "jwt"
|
||||||
- "jwt"
|
creds: "910517d9-f9a1-48de-8826-dbadacbd84af-cb6f830e-ab16-47ec-9d8f-0090de732774"
|
||||||
- "910517d9-f9a1-48de-8826-dbadacbd84af-cb6f830e-ab16-47ec-9d8f-0090de732774"
|
|
||||||
myhost.mydomain.com:
|
myhost.mydomain.com:
|
||||||
paths:
|
paths:
|
||||||
"/":
|
"/":
|
||||||
|
|||||||
@@ -1,37 +1,34 @@
|
|||||||
# The file is under watch and hot reload , changes are applied immediately, no need to restart or reload
|
# The file under watch and hot reload, changes are applied immediately, no need to restart or reload.
|
||||||
provider: "file" # consul
|
provider: "file" # consul
|
||||||
stickysessions: true
|
sticky_sessions: false
|
||||||
globals:
|
to_ssl: false
|
||||||
headers: # Global headers, appended for all upstreams and all paths.
|
headers:
|
||||||
- "Access-Control-Allow-Origin:*"
|
- "Access-Control-Allow-Origin:*"
|
||||||
- "Access-Control-Allow-Methods:POST, GET, OPTIONS"
|
- "Access-Control-Allow-Methods:POST, GET, OPTIONS"
|
||||||
- "Access-Control-Max-Age:86400"
|
- "Access-Control-Max-Age:86400"
|
||||||
- "X-Custom-Header:Something Special"
|
- "X-Custom-Header:Something Special"
|
||||||
# authorization: # Optional, only one of auth methods below can be active at a time
|
authorization:
|
||||||
# - "basic"
|
type: "jwt"
|
||||||
# - "gazan:Gazanpass1234"
|
creds: "910517d9-f9a1-48de-8826-dbadacbd84af-cb6f830e-ab16-47ec-9d8f-0090de732774"
|
||||||
# - "apikey"
|
# name: "basic"
|
||||||
# - "5a28cc4c-ce10-4ff1-824e-743c38835f5c"
|
# creds: "user:Passw0rd"
|
||||||
# - "jwt"
|
# name: "apikey"
|
||||||
# - "910517d9-f9a1-48de-8826-dbadacbd84af-cb6f830e-ab16-47ec-9d8f-0090de732774"
|
# creds: "5ecbf799-1343-4e94-a9b5-e278af5cd313-56b45249-1839-4008-a450-a60dc76d2bae"
|
||||||
consul: # If the provider is consul. Otherwise ignored
|
consul: # If the provider is consul. Otherwise, ignored.
|
||||||
servers:
|
servers:
|
||||||
- "http://master1:8500"
|
- "http://master1:8500"
|
||||||
- "http://192.168.22.1:8500"
|
- "http://192.168.22.1:8500"
|
||||||
- "http://master1.digitai.local:8500"
|
- "http://master1.foo.local:8500"
|
||||||
services: # proxy: The hostname to access proxy server, real : The real service name in Consul
|
services: # proxy: The hostname to access the proxy server, real : The real service name in Consul database.
|
||||||
- proxy: "proxy-frontend-dev-frontend-srv"
|
- proxy: "proxy-frontend-dev-frontend-srv"
|
||||||
real: "frontend-dev-frontend-srv"
|
real: "frontend-dev-frontend-srv"
|
||||||
# - proxy: "proxy-gateway-test-gateway-srv"
|
|
||||||
# real: "gateway-test-gateway-srv"
|
|
||||||
# - proxy: "proxy-backoffice-dev-backoffice-srv"
|
|
||||||
# real: "backoffice-dev-backoffice-srv"
|
|
||||||
token: "8e2db809-845b-45e1-8b47-2c8356a09da0-a4370955-18c2-4d6e-a8f8-ffcc0b47be81" # Consul server access token, If Consul auth is enabled
|
token: "8e2db809-845b-45e1-8b47-2c8356a09da0-a4370955-18c2-4d6e-a8f8-ffcc0b47be81" # Consul server access token, If Consul auth is enabled
|
||||||
upstreams: # If provider is files. Otherwise ignored
|
upstreams:
|
||||||
myip.netangels.net: # Hostname, or header host to access the upstream
|
myip.mydomain.com:
|
||||||
paths: # URL path(s) for current upstream, closest match wins
|
paths:
|
||||||
"/":
|
"/":
|
||||||
headers: # Custom headers, set only for this Host and Path
|
to_https: false
|
||||||
|
headers:
|
||||||
- "X-Proxy-From:Gazan"
|
- "X-Proxy-From:Gazan"
|
||||||
servers: # List of upstreams HOST:PORT
|
servers: # List of upstreams HOST:PORT
|
||||||
- "127.0.0.1:8000"
|
- "127.0.0.1:8000"
|
||||||
@@ -39,6 +36,7 @@ upstreams: # If provider is files. Otherwise ignored
|
|||||||
- "127.0.0.3:8000"
|
- "127.0.0.3:8000"
|
||||||
- "127.0.0.4:8000"
|
- "127.0.0.4:8000"
|
||||||
"/ping":
|
"/ping":
|
||||||
|
to_https: true
|
||||||
headers:
|
headers:
|
||||||
- "X-Some-Thing:Yaaaaaaaaaaaaaaa"
|
- "X-Some-Thing:Yaaaaaaaaaaaaaaa"
|
||||||
- "X-Proxy-From:Gazan"
|
- "X-Proxy-From:Gazan"
|
||||||
@@ -48,7 +46,7 @@ upstreams: # If provider is files. Otherwise ignored
|
|||||||
"/draw":
|
"/draw":
|
||||||
servers:
|
servers:
|
||||||
- "192.168.1.1:8000"
|
- "192.168.1.1:8000"
|
||||||
polo.netangels.net:
|
polo.mydomain.com:
|
||||||
paths:
|
paths:
|
||||||
"/":
|
"/":
|
||||||
headers:
|
headers:
|
||||||
@@ -60,36 +58,3 @@ upstreams: # If provider is files. Otherwise ignored
|
|||||||
- "127.0.0.2:8000"
|
- "127.0.0.2:8000"
|
||||||
- "127.0.0.3:8000"
|
- "127.0.0.3:8000"
|
||||||
- "127.0.0.4:8000"
|
- "127.0.0.4:8000"
|
||||||
glop.netangels.net:
|
|
||||||
paths:
|
|
||||||
"/":
|
|
||||||
headers:
|
|
||||||
- "X-Hopar-From:Hopaaaaaaaaaaaar"
|
|
||||||
servers:
|
|
||||||
- "192.168.1.10:8000"
|
|
||||||
- "192.168.1.1:8000"
|
|
||||||
apt.netangels.net:
|
|
||||||
paths:
|
|
||||||
"/":
|
|
||||||
servers:
|
|
||||||
- "apt.netangels.net:443"
|
|
||||||
test.netangels.net:
|
|
||||||
paths:
|
|
||||||
"/":
|
|
||||||
servers:
|
|
||||||
- "myip.netangels.net:80"
|
|
||||||
127.0.0.1:
|
|
||||||
paths:
|
|
||||||
"/":
|
|
||||||
servers:
|
|
||||||
- "192.168.1.5:8080"
|
|
||||||
127.0.0.2:
|
|
||||||
paths:
|
|
||||||
"/":
|
|
||||||
servers:
|
|
||||||
- "10.0.55.171:3000"
|
|
||||||
localpost:
|
|
||||||
paths:
|
|
||||||
"/":
|
|
||||||
servers:
|
|
||||||
- "127.0.0.1:9000"
|
|
||||||
@@ -47,12 +47,10 @@ pub fn load_configuration(d: &str, kind: &str) -> Option<Configuration> {
|
|||||||
Ok(parsed) => {
|
Ok(parsed) => {
|
||||||
let global_headers = DashMap::new();
|
let global_headers = DashMap::new();
|
||||||
let mut hl = Vec::new();
|
let mut hl = Vec::new();
|
||||||
if let Some(globals) = &parsed.globals {
|
if let Some(headers) = &parsed.headers {
|
||||||
for headers in globals.get("headers").iter().by_ref() {
|
for header in headers.iter() {
|
||||||
for header in headers.iter() {
|
if let Some((key, val)) = header.split_once(':') {
|
||||||
if let Some((key, val)) = header.split_once(':') {
|
hl.push((key.to_string(), val.to_string()));
|
||||||
hl.push((key.to_string(), val.to_string()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
global_headers.insert("/".to_string(), hl);
|
global_headers.insert("/".to_string(), hl);
|
||||||
@@ -60,15 +58,16 @@ pub fn load_configuration(d: &str, kind: &str) -> Option<Configuration> {
|
|||||||
|
|
||||||
toreturn.extraparams.sticky_sessions = parsed.sticky_sessions;
|
toreturn.extraparams.sticky_sessions = parsed.sticky_sessions;
|
||||||
toreturn.extraparams.to_ssl = parsed.to_ssl;
|
toreturn.extraparams.to_ssl = parsed.to_ssl;
|
||||||
|
|
||||||
let cfg = DashMap::new();
|
|
||||||
if let Some(k) = globals.get("authorization") {
|
|
||||||
cfg.insert("authorization".to_string(), k.to_owned());
|
|
||||||
toreturn.extraparams.authentication = cfg;
|
|
||||||
} else {
|
|
||||||
toreturn.extraparams.authentication = DashMap::new();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if let Some(auth) = &parsed.authorization {
|
||||||
|
let name = auth.get("type").unwrap().to_string();
|
||||||
|
let creds = auth.get("creds").unwrap().to_string();
|
||||||
|
let val: Vec<String> = vec![name, creds];
|
||||||
|
toreturn.extraparams.authentication.insert("authorization".to_string(), val);
|
||||||
|
} else {
|
||||||
|
toreturn.extraparams.authentication = DashMap::new();
|
||||||
|
}
|
||||||
|
|
||||||
match parsed.provider.as_str() {
|
match parsed.provider.as_str() {
|
||||||
"file" => {
|
"file" => {
|
||||||
toreturn.typecfg = "file".to_string();
|
toreturn.typecfg = "file".to_string();
|
||||||
@@ -77,7 +76,6 @@ pub fn load_configuration(d: &str, kind: &str) -> Option<Configuration> {
|
|||||||
let path_map = DashMap::new();
|
let path_map = DashMap::new();
|
||||||
let header_list = DashMap::new();
|
let header_list = DashMap::new();
|
||||||
for (path, path_config) in host_config.paths {
|
for (path, path_config) in host_config.paths {
|
||||||
// println!("{:?}", path_config);
|
|
||||||
let mut server_list = Vec::new();
|
let mut server_list = Vec::new();
|
||||||
let mut hl = Vec::new();
|
let mut hl = Vec::new();
|
||||||
if let Some(headers) = &path_config.headers {
|
if let Some(headers) = &path_config.headers {
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ pub struct Config {
|
|||||||
pub to_ssl: Option<bool>,
|
pub to_ssl: Option<bool>,
|
||||||
pub upstreams: Option<HashMap<String, HostConfig>>,
|
pub upstreams: Option<HashMap<String, HostConfig>>,
|
||||||
pub globals: Option<HashMap<String, Vec<String>>>,
|
pub globals: Option<HashMap<String, Vec<String>>>,
|
||||||
|
pub headers: Option<Vec<String>>,
|
||||||
|
pub authorization: Option<HashMap<String, String>>,
|
||||||
pub consul: Option<Consul>,
|
pub consul: Option<Consul>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user