From 040f1ed1895dcb04f502206d5413ebf80894dcb2 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Thu, 12 Oct 2023 08:53:28 -0300 Subject: [PATCH 01/11] feat: add expose and listen on 8080 --- Dockerfile | 2 ++ src/main.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3dcd06b..b0316de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,4 +30,6 @@ RUN apt-get update && apt install -y openssl libssl-dev COPY --from=build /presence/target/release/presence . +EXPOSE 8080 + CMD ["./presence"] diff --git a/src/main.rs b/src/main.rs index c1cb456..db430c3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -131,7 +131,7 @@ async fn main() -> std::io::Result<()> { .app_data(web::Data::new(state.clone())) .route("/", web::get().to(connect_handler)) }) - .bind("127.0.0.1:80")? + .bind("127.0.0.1:8080")? .run() .await } From f8c5d65e036b03a9975e12fb0d254a89e848c110 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Thu, 12 Oct 2023 09:02:47 -0300 Subject: [PATCH 02/11] feat: in main rs 0.0.0.0:8080 --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index db430c3..39385c6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -131,7 +131,7 @@ async fn main() -> std::io::Result<()> { .app_data(web::Data::new(state.clone())) .route("/", web::get().to(connect_handler)) }) - .bind("127.0.0.1:8080")? + .bind("0.0.0.0:8080")? .run() .await } From 7aba5a6491db77630db5d4ca67d6428f8217c627 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Thu, 12 Oct 2023 09:14:52 -0300 Subject: [PATCH 03/11] feat: add default location for ACME cerf --- nginx.conf.sigil | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nginx.conf.sigil b/nginx.conf.sigil index 4df3952..d1b1f97 100644 --- a/nginx.conf.sigil +++ b/nginx.conf.sigil @@ -45,6 +45,13 @@ server { {{ end }} # Default location block + + # Let's Encrypt ACME Challenge + location ^~ /.well-known/acme-challenge/ { + root /var/www/letsencrypt/; + try_files $uri =404; + } + location / { proxy_pass http://{{ $.APP }}-{{ $upstream_port }}; {{ $proxy_settings }} From 8e48b49a3f6179e12a9b5edcefe1e44702ecac15 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Thu, 12 Oct 2023 09:24:20 -0300 Subject: [PATCH 04/11] feat: ACME location in main too --- src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.rs b/src/main.rs index 39385c6..3fb12fd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -130,6 +130,7 @@ async fn main() -> std::io::Result<()> { .wrap(Logger::default()) .app_data(web::Data::new(state.clone())) .route("/", web::get().to(connect_handler)) + .service(Files::new("/.well-known/acme-challenge/", "/var/www/letsencrypt/.well-known/acme-challenge/")) }) .bind("0.0.0.0:8080")? .run() From 3e5f96633a3f9f9f4fdc99f45cef88146d356a10 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Thu, 12 Oct 2023 09:25:55 -0300 Subject: [PATCH 05/11] feat: ACME location in main too --- Cargo.toml | 1 + src/main.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 29ed16a..87b3494 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" reqwest = { version = "0.11", features = ["json"] } futures = "0.3.28" +actix-files = "0.3" [[bin]] name = "presence" diff --git a/src/main.rs b/src/main.rs index 3fb12fd..7ceb74f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,8 @@ use tokio::sync::broadcast; use actix_web::error::{ErrorUnauthorized, ErrorInternalServerError as ServerError}; use std::sync::{Arc, Mutex}; use tokio::task::JoinHandle; +use actix_files::Files; + mod data; From 123c8acee61e6fbcc6d53a73c8415cf5ed15b5d0 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Thu, 12 Oct 2023 09:32:35 -0300 Subject: [PATCH 06/11] feat: ACME location in main too --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 7ceb74f..315fd85 100644 --- a/src/main.rs +++ b/src/main.rs @@ -132,7 +132,8 @@ async fn main() -> std::io::Result<()> { .wrap(Logger::default()) .app_data(web::Data::new(state.clone())) .route("/", web::get().to(connect_handler)) - .service(Files::new("/.well-known/acme-challenge/", "/var/www/letsencrypt/.well-known/acme-challenge/")) + .service(Files::new("/.well-known/acme-challenge/").show_files_listing() + ) }) .bind("0.0.0.0:8080")? .run() From e74efc5aec97518806636df4caf4e3d3ac3ca93f Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Thu, 12 Oct 2023 09:35:15 -0300 Subject: [PATCH 07/11] feat: ACME location in main too --- Cargo.toml | 2 +- src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 87b3494..22fd689 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" reqwest = { version = "0.11", features = ["json"] } futures = "0.3.28" -actix-files = "0.3" +actix-files = "0.6" [[bin]] name = "presence" diff --git a/src/main.rs b/src/main.rs index 315fd85..2c79a1b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -132,7 +132,7 @@ async fn main() -> std::io::Result<()> { .wrap(Logger::default()) .app_data(web::Data::new(state.clone())) .route("/", web::get().to(connect_handler)) - .service(Files::new("/.well-known/acme-challenge/").show_files_listing() + .service(Files::new("/.well-known/acme-challenge/", "/var/www/letsencrypt/.well-known/acme-challenge/") ) }) .bind("0.0.0.0:8080")? From 7503b4cecf83ac5c88aff98269625a9d2cc6af67 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Thu, 12 Oct 2023 09:47:17 -0300 Subject: [PATCH 08/11] feat: Dockerfile with ACME dir --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index b0316de..e95d0bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,10 @@ RUN apt-get update -y && \ apt-get install -y git pkg-config make g++ libssl-dev wget && \ rustup target add x86_64-unknown-linux-gnu +# Create the directory for Let's Encrypt challenges +RUN mkdir -p /var/www/letsencrypt/.well-known/acme-challenge/ && \ + chown -R www-data:www-data /var/www/letsencrypt/ + RUN USER=root cargo new --bin presence WORKDIR /presence From 10453851c2c97ba9e925db8db1a199ea5f38bd99 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Thu, 12 Oct 2023 09:56:13 -0300 Subject: [PATCH 09/11] feat: Dockerfile with ACME dir --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index e95d0bf..4eea309 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,10 +5,6 @@ RUN apt-get update -y && \ apt-get install -y git pkg-config make g++ libssl-dev wget && \ rustup target add x86_64-unknown-linux-gnu -# Create the directory for Let's Encrypt challenges -RUN mkdir -p /var/www/letsencrypt/.well-known/acme-challenge/ && \ - chown -R www-data:www-data /var/www/letsencrypt/ - RUN USER=root cargo new --bin presence WORKDIR /presence @@ -36,4 +32,8 @@ COPY --from=build /presence/target/release/presence . EXPOSE 8080 +# Create the directory for Let's Encrypt challenges +RUN mkdir -p /var/www/letsencrypt/.well-known/acme-challenge/ && \ + chown -R www-data:www-data /var/www/letsencrypt/ + CMD ["./presence"] From 61b9eb23270aeccbd8ea6fb4d18dceffd588cab3 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Thu, 12 Oct 2023 10:00:27 -0300 Subject: [PATCH 10/11] debug: routing to acme only from nginx --- Cargo.toml | 1 - src/main.rs | 2 -- 2 files changed, 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 22fd689..29ed16a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,6 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" reqwest = { version = "0.11", features = ["json"] } futures = "0.3.28" -actix-files = "0.6" [[bin]] name = "presence" diff --git a/src/main.rs b/src/main.rs index 2c79a1b..0e6c476 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,6 @@ use tokio::sync::broadcast; use actix_web::error::{ErrorUnauthorized, ErrorInternalServerError as ServerError}; use std::sync::{Arc, Mutex}; use tokio::task::JoinHandle; -use actix_files::Files; mod data; @@ -132,7 +131,6 @@ async fn main() -> std::io::Result<()> { .wrap(Logger::default()) .app_data(web::Data::new(state.clone())) .route("/", web::get().to(connect_handler)) - .service(Files::new("/.well-known/acme-challenge/", "/var/www/letsencrypt/.well-known/acme-challenge/") ) }) .bind("0.0.0.0:8080")? From 51c250a4ae1d314c578720439843ceb4e872b7b7 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Thu, 12 Oct 2023 10:01:17 -0300 Subject: [PATCH 11/11] debug: routing to acme only from nginx --- src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 0e6c476..36d75ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -131,7 +131,6 @@ async fn main() -> std::io::Result<()> { .wrap(Logger::default()) .app_data(web::Data::new(state.clone())) .route("/", web::get().to(connect_handler)) - ) }) .bind("0.0.0.0:8080")? .run()