raftario / filite

A simple, light and standalone pastebin, URL shortener and file-sharing service
MIT License
190 stars 16 forks source link

Allow custom host to bind to #28

Open catthehacker opened 4 years ago

catthehacker commented 4 years ago

This allows for filite to work in edge(?) cases where binding to localhost is not enough. Binding to localhost or 127.0.0.1 allows the app to be accessible only by the host itself and with sandboxed network configuration this makes it impossible to have it accessible in certain setups. I've made quick change to current source to allow it but I'm not good at Rust. https://github.com/CatTheHacker/filite/commit/df89d52ae8fd513f4442d849e87bb7bfc1502fd6

Also in case of using reverse proxy in front of filite, it would be nice to have an option to use UNIX sockets to bypass network completely

diff --git a/src/main.rs b/src/main.rs
index 62cfd45..245d5e9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -95,7 +95,7 @@ async fn main() {
                     .route(web::delete().to(routes::texts::delete)),
             )
     })
-    .bind(&format!("{}:{}", host, port))
+    .bind_uds("/path/cat/.local/tmp/filite.sock")
     .unwrap_or_else(|e| {
         eprintln!("Can't bind webserver to specified port: {}", e);
         process::exit(1);

Nginx:

proxy_pass http://unix:/path/cat/.local/tmp/filite.sock:/
raftario commented 4 years ago

Pretty sure that's configurable on the next branch but I'll double check. I'll also add unix socket support there, thanks for the suggestion. I don't plan on making any improvements to master myself since next is a complete rewrite and will replace it soon-ish (hopefully, but I haven't got a whole lot of free time to put in it at the moment), but if you open a PR I'll merge it.

ghost commented 2 years ago

Any news here?