Skip to content

This commit resolves #98 so custom ___location can forward to custom path. #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/backend/internal/nginx.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,16 @@ const internalNginx = {

const locationRendering = async () => {
for (let i = 0; i < host.locations.length; i++) {
renderedLocations += await renderer.parseAndRender(template, host.locations[i]);
let locationCopy = Object.assign({}, host.locations[i]);

if (locationCopy.forward_host.indexOf('/') > -1) {
const splitted = locationCopy.forward_host.split('/');

locationCopy.forward_host = splitted.shift();
locationCopy.forward_path = `/${splitted.join('/')}`;
}

renderedLocations += await renderer.parseAndRender(template, locationCopy);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/backend/schema/endpoints/proxy-hosts.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
"forward_port": {
"$ref": "#/definitions/forward_port"
},
"forward_path": {
"type": "string"
},
"advanced_config": {
"type": "string"
}
Expand Down
2 changes: 1 addition & 1 deletion src/backend/templates/_location.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }};
proxy_pass {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }}{{ forward_path }};
{{ advanced_config }}
}

1 change: 1 addition & 0 deletions src/frontend/js/app/nginx/proxy/___location-item.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<div class="form-group">
<label class="form-label"><%- i18n('proxy-hosts', 'forward-host') %><span class="form-required">*</span></label>
<input type="text" name="forward_host" class="form-control text-monospace model" placeholder="" value="<%- forward_host %>" autocomplete="off" maxlength="50" required>
<span style="font-size: 9px;"><%- i18n('proxy-hosts', 'cutom-forward-host-help') %></span>
</div>
</div>
<div class="col-sm-4 col-md-4">
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/js/i18n/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
"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.",
"access-list": "Access List",
"allow-websocket-upgrade": "Websockets Support",
"ignore-invalid-upstream-ssl": "Ignore Invalid SSL"
"ignore-invalid-upstream-ssl": "Ignore Invalid SSL",
"cutom-forward-host-help": "Use 1.1.1.1/path for sub-folder forwarding"
},
"redirection-hosts": {
"title": "Redirection Hosts",
Expand Down