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 ef0471f commit 189d3bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bin/ncproxy/src/models/templates/http.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ 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 }}{{ location.upstream_path }};{% else %}
return {{ location.redirect }} {{ location.upstream_key }};{% else %}
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass {{ location.upstream_key }}/;
proxy_pass {{ location.upstream_key }}{{ location.upstream_path }};
{% endif %}{% if location.allowed_ips %}{% for allowed_ip in location.allowed_ips %}
allow {{ allowed_ip }};
{% endfor %}deny all;{% endif %}
Expand Down
6 changes: 3 additions & 3 deletions bin/ncproxy/src/utils/nginx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +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()),
upstream_path: upstream.path.clone().unwrap_or("/".to_owned()),
version: location.version,
allowed_ips: location.allowed_ips.clone(),
headers: location.headers.clone(),
Expand All @@ -200,7 +200,7 @@ pub async fn add_rule(
path: location.path.clone(),
upstream_key: format!("http://{upstream_key}"),
redirect: None,
upstream_path: "".to_owned(),
upstream_path: "/".to_owned(),
version: location.version,
allowed_ips: location.allowed_ips.clone(),
headers: location.headers.clone(),
Expand All @@ -212,7 +212,7 @@ pub async fn add_rule(
path: location.path.clone(),
upstream_key: http.url.clone(),
version: location.version,
upstream_path: "".to_owned(),
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 189d3bd

Please sign in to comment.