attempt to fix tor/lan urls for main ui

This commit is contained in:
Keagan McClelland
2021-10-11 14:46:08 -06:00
committed by Aiden McClelland
parent f7556b78c5
commit 0f0403e8d7
3 changed files with 96 additions and 46 deletions

View File

@@ -3,6 +3,7 @@ use std::time::Duration;
use color_eyre::eyre::eyre;
use embassy::context::{DiagnosticContext, RpcContext};
use embassy::db::subscribe;
use embassy::hostname::get_hostname;
use embassy::middleware::auth::auth;
use embassy::middleware::cors::cors;
use embassy::middleware::diagnostic::diagnostic;
@@ -66,10 +67,17 @@ async fn inner_main(cfg_path: Option<&str>) -> Result<Option<Shutdown>, Error> {
.expect("send shutdown signal");
});
tokio::fs::write(
"/etc/nginx/sites-available/default",
include_str!("../nginx/main-ui.conf"),
)
tokio::fs::write("/etc/nginx/sites-available/default", {
let info = embassy::db::DatabaseModel::new()
.server_info()
.get(&mut rpc_ctx.db.handle(), true)
.await?;
format!(
include_str!("../nginx/main-ui.conf.template"),
lan_hostname = info.lan_address.host_str().unwrap(),
tor_hostname = info.tor_address.host_str().unwrap()
)
})
.await
.with_ctx(|_| {
(

View File

@@ -1,42 +0,0 @@
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl_certificate /etc/nginx/ssl/embassy_main.cert.pem;
ssl_certificate_key /etc/nginx/ssl/embassy_main.key.pem;
root /var/www/html/main;
index index.html index.htm index.nginx-debian.html;
server_name _;
proxy_buffering off;
proxy_request_buffering off;
proxy_socket_keepalive on;
proxy_http_version 1.1;
proxy_read_timeout 1800;
location /rpc/ {
proxy_pass http://127.0.0.1:5959/;
}
location /ws/ {
proxy_pass http://127.0.0.1:5960/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location /marketplace/ {
proxy_pass https://beta-registry-0-3.start9labs.com/; # TODO
}
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}

View File

@@ -0,0 +1,84 @@
server {{
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl_certificate /etc/nginx/ssl/embassy_main.cert.pem;
ssl_certificate_key /etc/nginx/ssl/embassy_main.key.pem;
root /var/www/html/main;
index index.html index.htm index.nginx-debian.html;
server_name {lan_hostname};
proxy_buffering off;
proxy_request_buffering off;
proxy_socket_keepalive on;
proxy_http_version 1.1;
proxy_read_timeout 1800;
location /rpc/ {{
proxy_pass http://127.0.0.1:5959/;
}}
location /ws/ {{
proxy_pass http://127.0.0.1:5960/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}}
location /marketplace/ {{
proxy_pass https://beta-registry-0-3.start9labs.com/; # TODO
}}
location / {{
try_files $uri $uri/ =404;
}}
}}
server {{
listen 80;
listen [::]:80;
server_name {lan_hostname};
return 301 https://$host$request_uri;
}}
server {{
listen 80 default_server;
listen [::]:80 default_server;
ssl_certificate /etc/nginx/ssl/embassy_main.cert.pem;
ssl_certificate_key /etc/nginx/ssl/embassy_main.key.pem;
root /var/www/html/main;
index index.html index.htm index.nginx-debian.html;
server_name {tor_hostname};
proxy_buffering off;
proxy_request_buffering off;
proxy_socket_keepalive on;
proxy_http_version 1.1;
proxy_read_timeout 1800;
location /rpc/ {{
proxy_pass http://127.0.0.1:5959/;
}}
location /ws/ {{
proxy_pass http://127.0.0.1:5960/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}}
location /marketplace/ {{
proxy_pass https://beta-registry-0-3.start9labs.com/; # TODO
}}
location / {{
try_files $uri $uri/ =404;
}}
}}
server {{
listen 443 ssl;
listen [::]:443;
server_name {tor_hostname};
return 301 http://$host$request_uri;
}}