Compare commits

...

3 Commits
v1.3.0 ... main

Author SHA1 Message Date
a4cfb64155 Add CHELA_USES_HTTPS as an option
Some checks failed
Build and Push Docker Image / docker (push) Failing after 1m2s
2024-05-01 12:32:28 -04:00
84f5f57ade Add LICENSE 2024-04-08 07:29:42 -04:00
c733d4c98f Fix example nginx config issue in README.md 2024-04-08 07:24:32 -04:00
6 changed files with 39 additions and 8 deletions

2
Cargo.lock generated
View File

@ -215,7 +215,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chela"
version = "1.3.0"
version = "1.4.0"
dependencies = [
"axum",
"chrono",

View File

@ -1,7 +1,8 @@
[package]
name = "chela"
version = "1.3.0"
version = "1.4.0"
edition = "2021"
license = "BSL-1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

23
LICENSE Normal file
View File

@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@ -71,6 +71,9 @@ If you would like Chela to listen for HTTP requests over a Unix socket, set this
##### `CHELA_ALPHABET`
If this variable is set, Chela will use the characters in `CHELA_ALPHABET` to create IDs for URLs. The default alphabet is `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`. See [here](https://sqids.org/faq#unique) for more information on Sqids alphabets.
##### `CHELA_USES_HTTPS`
If this variable is set, Chela will refer to itself as `https://$CHELA_HOST` instead of the default `http://$CHELA_HOST`.
### Manually
#### Build
```bash
@ -94,10 +97,10 @@ If you would prefer to be the only one able to access these pages, then you can
```nginx
server {
server_name example.com;
server_name a.com;
location / {
proxy_pass http://localhost:3000/;
proxy_pass http://localhost:3000;
proxy_set_header X-Real-IP $remote_addr;
limit_except GET HEAD {
@ -107,8 +110,7 @@ server {
}
location /tracking {
proxy_pass http://localhost:3000/;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:3000$request_uri;
auth_basic 'Restricted';
auth_basic_user_file /path/to/your/.htpasswd;

View File

@ -29,6 +29,7 @@ pub struct ServerState {
pub sqids: Sqids,
pub main_page_redirect: Option<Url>,
pub behind_proxy: bool,
pub uses_https: bool,
}
#[derive(Debug, Clone, sqlx::FromRow, PartialEq, Eq)]
@ -87,12 +88,14 @@ async fn main() -> eyre::Result<()> {
.build()?;
let main_page_redirect = env::var("CHELA_MAIN_PAGE_REDIRECT").unwrap_or_default();
let behind_proxy = env::var("CHELA_BEHIND_PROXY").is_ok();
let uses_https = env::var("CHELA_USES_HTTPS").is_ok();
let server_state = ServerState {
db_pool,
host,
sqids,
main_page_redirect: Url::parse(&main_page_redirect).ok(),
behind_proxy,
uses_https
};
serve(server_state).await?;

View File

@ -32,7 +32,8 @@ pub async fn create_link(
if id.exists {
log!("Serving cached id {} -> {}", id.id, form.url.as_str());
return Html(format!(
r#"<pre>http://{}/{} -> <a href="{}"">{}</a></pre>"#,
r#"<pre>http{}://{}/{} -> <a href="{}"">{}</a></pre>"#,
if state.uses_https { "s" } else { "" },
state.host,
id.id,
form.url.as_str(),
@ -72,7 +73,8 @@ VALUES ($1,$2,true)
return (
StatusCode::OK,
Html(format!(
r#"<pre>http://{}/{} -> <a href="{}"">{}</a></pre>"#,
r#"<pre>http{}://{}/{} -> <a href="{}"">{}</a></pre>"#,
if state.uses_https { "s" } else { "" },
state.host,
id.id,
form.url.as_str(),