Skip to content

Commit d79fcbf

Browse files
kolbiijc21
authored andcommitted
This commit resolves #98 so custom location can forward to custom path. (#99)
Awesome work!
1 parent 631d9ae commit d79fcbf

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

src/backend/internal/nginx.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,16 @@ const internalNginx = {
151151

152152
const locationRendering = async () => {
153153
for (let i = 0; i < host.locations.length; i++) {
154-
renderedLocations += await renderer.parseAndRender(template, host.locations[i]);
154+
let locationCopy = Object.assign({}, host.locations[i]);
155+
156+
if (locationCopy.forward_host.indexOf('/') > -1) {
157+
const splitted = locationCopy.forward_host.split('/');
158+
159+
locationCopy.forward_host = splitted.shift();
160+
locationCopy.forward_path = `/${splitted.join('/')}`;
161+
}
162+
163+
renderedLocations += await renderer.parseAndRender(template, locationCopy);
155164
}
156165
}
157166

src/backend/schema/endpoints/proxy-hosts.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@
9999
"forward_port": {
100100
"$ref": "#/definitions/forward_port"
101101
},
102+
"forward_path": {
103+
"type": "string"
104+
},
102105
"advanced_config": {
103106
"type": "string"
104107
}

src/backend/templates/_location.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
proxy_set_header X-Forwarded-Scheme $scheme;
44
proxy_set_header X-Forwarded-Proto $scheme;
55
proxy_set_header X-Forwarded-For $remote_addr;
6-
proxy_pass {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }};
6+
proxy_pass {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }}{{ forward_path }};
77
{{ advanced_config }}
88
}
99

src/frontend/js/app/nginx/proxy/location-item.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<div class="form-group">
4040
<label class="form-label"><%- i18n('proxy-hosts', 'forward-host') %><span class="form-required">*</span></label>
4141
<input type="text" name="forward_host" class="form-control text-monospace model" placeholder="" value="<%- forward_host %>" autocomplete="off" maxlength="50" required>
42+
<span style="font-size: 9px;"><%- i18n('proxy-hosts', 'cutom-forward-host-help') %></span>
4243
</div>
4344
</div>
4445
<div class="col-sm-4 col-md-4">

src/frontend/js/i18n/messages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@
114114
"help-content": "A Proxy Host is the incoming endpoint for a web service that you want to forward.\nIt provides optional SSL termination for your service that might not have SSL support built in.\nProxy Hosts are the most common use for the Nginx Proxy Manager.",
115115
"access-list": "Access List",
116116
"allow-websocket-upgrade": "Websockets Support",
117-
"ignore-invalid-upstream-ssl": "Ignore Invalid SSL"
117+
"ignore-invalid-upstream-ssl": "Ignore Invalid SSL",
118+
"cutom-forward-host-help": "Use 1.1.1.1/path for sub-folder forwarding"
118119
},
119120
"redirection-hosts": {
120121
"title": "Redirection Hosts",

0 commit comments

Comments
 (0)