Git Product home page Git Product logo

Comments (4)

finnbear avatar finnbear commented on June 24, 2024 1

We have fixed this in our private upstream repository but haven't open-sourced it yet.

Until then, consider editing this line to use whatever port numbers you want:

let ports = (self.http_port.unwrap_or(default_ports.0), default_ports.1);

// (http, https)
let ports = (123, 456);

from mk48.

Stevie0427 avatar Stevie0427 commented on June 24, 2024 1

Thanks for your answering.

from mk48.

Stevie0427 avatar Stevie0427 commented on June 24, 2024

OK, so how can I disable HTTPS? Because I would like to use nginx to proxy it and enable HTTPS on the source site make the configuration more complex.

from mk48.

finnbear avatar finnbear commented on June 24, 2024

Hmm, that's a different code change. Go here:

#[cfg(not(debug_assertions))]
let http_app = Router::new()
.fallback_service(get(async move |uri: Uri, host: TypedHeader<axum::headers::Host>, headers: reqwest::header::HeaderMap| {
if let Err(response) = limit_content_length(&headers, 16384) {
return Err(response);
}
let mut parts = uri.into_parts();
parts.scheme = Some(Scheme::HTTPS);
let authority = if https_port == Options::STANDARD_HTTPS_PORT {
Authority::from_str(host.0.hostname())
} else {
// non-standard port.
Authority::from_str(&format!("{}:{}", host.0.hostname(), https_port))
}.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response())?;
parts.authority = Some(authority);
Uri::from_parts(parts)
.map(|uri| if http_port == Options::STANDARD_HTTP_PORT { Redirect::permanent(&uri.to_string()) } else { Redirect::temporary(&uri.to_string()) })
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response())
}));
#[cfg(debug_assertions)]
let http_app = app;
let http_server = axum_server::bind(SocketAddr::from(([0, 0, 0, 0], http_port)))
.addr_incoming_config(addr_incoming_config.clone())
.http_config(http_config.clone())
.serve(http_app.into_make_service_with_connect_info::<SocketAddr>());
#[cfg(debug_assertions)]
error!("http server stopped: {:?}", http_server.await);
#[cfg(not(debug_assertions))]
let rustls_config = if let Some((certificate_path, private_key_path)) = certificate_paths {
let rustls_config = axum_server::tls_rustls::RustlsConfig::from_pem_file(
certificate_path,
private_key_path,
).await.unwrap();
let renewal_rustls_config = rustls_config.clone();
let certificate_path = certificate_path.to_owned();
let private_key_path = private_key_path.to_owned();
tokio::spawn(async move {
let mut old_expiry = server_util::ssl::certificate_expiry(&certificate_path).unwrap();
let mut governor = tokio::time::interval(Duration::from_secs(24 * 60 * 60));
loop {
// Every day.
governor.tick().await;
match server_util::ssl::certificate_expiry(&certificate_path) {
Ok(new_expiry) => {
if new_expiry > old_expiry {
warn!("renewing SSL certificate...");
if let Err(e) = renewal_rustls_config.reload_from_pem_file(&certificate_path, &private_key_path).await {
error!("failed to renew SSL certificate: {}", e);
} else {
old_expiry = new_expiry;
}
} else {
log::info!("SSL certificate not in need of renewal.");
}
}
Err(e) => error!("failed to get SSL certificate expiry: {}", e)
}
}
});
rustls_config
} else {
warn!("Using self-signed certificate in place of trusted certificate.");
axum_server::tls_rustls::RustlsConfig::from_pem(
include_bytes!("certificate.pem").as_slice().into(),
include_bytes!("private_key.pem").as_slice().into(),
).await.unwrap()
};
#[cfg(not(debug_assertions))]
let https_server = axum_server::bind_rustls(SocketAddr::from(([0, 0, 0, 0], https_port)), rustls_config)
.addr_incoming_config(addr_incoming_config.clone())
.http_config(http_config)
.serve(app.into_make_service_with_connect_info::<SocketAddr>());
#[cfg(not(debug_assertions))]
tokio::select! {
result = http_server => {
error!("http server stopped: {:?}", result);
}
result = https_server => {
error!("https server stopped: {:?}", result);
}
}

Remove all #[cfg(debug_assertions)]'s and delete all lines right after #[cfg(not(debug_assertions))]'s. Debug was HTTP-only, this change just hardcodes HTTP-only.

from mk48.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.