Skip to content

Commit

Permalink
fix/ncproxy: set upstream target path
Browse files Browse the repository at this point in the history
  • Loading branch information
leon3s committed May 1, 2024
1 parent 06b8777 commit 720d40e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions bin/ncproxy/src/models/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use nanocl_error::io::{IoResult, IoError};
pub struct LocationTemplate {
pub path: String,
pub upstream_key: String,
pub upstream_path: String,
pub redirect: Option<String>,
pub allowed_ips: Option<Vec<String>>,
pub version: Option<f64>,
Expand Down
2 changes: 1 addition & 1 deletion bin/ncproxy/src/models/templates/http.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ server {
proxy_set_header {{ header }};
{% endfor %}{% endif %}{% if location.version %}proxy_http_version {{ location.version }};
{% endif %}{% if location.redirect %}
return {{ location.redirect }} {{ location.upstream_key }};{% else %}
return {{ location.redirect }} {{ location.upstream_key }}{{ location.upstream_path }};{% else %}
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
Expand Down
3 changes: 3 additions & 0 deletions bin/ncproxy/src/utils/nginx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ pub async fn add_rule(
path: location.path.clone(),
upstream_key: format!("http://{upstream_key}"),
redirect: None,
upstream_path: upstream.path.clone().unwrap_or("/".to_owned()),
version: location.version,
allowed_ips: location.allowed_ips.clone(),
headers: location.headers.clone(),
Expand All @@ -199,6 +200,7 @@ pub async fn add_rule(
path: location.path.clone(),
upstream_key: format!("http://{upstream_key}"),
redirect: None,
upstream_path: "/".to_owned(),
version: location.version,
allowed_ips: location.allowed_ips.clone(),
headers: location.headers.clone(),
Expand All @@ -210,6 +212,7 @@ pub async fn add_rule(
path: location.path.clone(),
upstream_key: http.url.clone(),
version: location.version,
upstream_path: "/".to_owned(),
allowed_ips: location.allowed_ips.clone(),
headers: location.headers.clone(),
redirect: http.redirect.clone().map(|r| format!("{r}")),
Expand Down

0 comments on commit 720d40e

Please sign in to comment.