Skip to content
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

Support different mount-point / path for webserver #129

Open
SpraxDev opened this issue Oct 28, 2022 · 0 comments
Open

Support different mount-point / path for webserver #129

SpraxDev opened this issue Oct 28, 2022 · 0 comments

Comments

@SpraxDev
Copy link

SpraxDev commented Oct 28, 2022

I'm currently trying to setup a couple of warriors using the official Docker images.
I wanted to host all of them behind one convenient domain like warriors.example.com/reddit/ using nginx as my reverse proxy.

This already works for the assets loaded but seems to break for the SockJS-Script.
It is requesting /info instead of /reddit/info in my case (same goes for /api/all-projects).

The problem seems to be at

var conn = new SockJS(window.location.protocol + '//' + window.location.host);

and got introduces in fa11921.


I couldn't find any reason for SockJS getting a custom built URL in the first place instead of just providing the current URL. Maybe adding the current path or using the current full URL would work here as SockJS already preprocessed the given URL?
(var conn = new SockJS(window.location.protocol + '//' + window.location.host + window.location.pathname);)

utils.amendUrl = function(url) {
var dl = _document.location;
if (!url) {
throw new Error('Wrong url for SockJS');
}
if (!utils.flatUrl(url)) {
throw new Error('Only basic urls are supported in SockJS');
}
// '//abc' --> 'http://abc'
if (url.indexOf('//') === 0) {
url = dl.protocol + url;
}
// '/abc' --> 'http://localhost:80/abc'
if (url.indexOf('/') === 0) {
url = dl.protocol + '//' + dl.host + url;
}
// strip trailing slashes
url = url.replace(/[/]+$/,'');
return url;
};


To fix the /api routes it should be possible to just let the browser handle everything and calling a relative uri at

function reloadProjectsTab() {
$('#projects').load('/api/all-projects', null, function() {
$("#projects input[type='submit']").each(makeButtonLink);
$("#projects li").each(addProjectCountdown);
});
}
function reloadSettingsTab() {
$('#settings-list').load('/api/settings');
}
function reloadHelpTab() {
$('#help').load('/api/help');
$('#broadcastMessage-indicator').hide();
if (localStorage) {
localStorage.lastReadBroadcastMessageHash = currentBroadcastMessageHash;
}
}
var warriorStatus = {
'UNINITIALIZED': ['The warrior could not contact HQ. Please reboot.', 'Shut down', '/api/stop'],
'NO_PROJECT': ['The warrior is idle. Select a project.', 'Shut down', '/api/stop'],
'INVALID_SETTINGS': ['You must configure the warrior.', 'Shut down', '/api/stop'],
'STOPPING_PROJECT': ['The warrior is stopping the current project.', 'Shut down', '/api/stop'],
'RESTARTING_PROJECT': ['The warrior is restarting the current project.', 'Shut down', '/api/stop'],
'RUNNING_PROJECT': ['The warrior is working on a project.', 'Shut down', '/api/stop'],
'SWITCHING_PROJECT': ['The warrior will switch to a different project.', 'Shut down', '/api/stop'],
'STARTING_PROJECT': ['The warrior is beginning work on a project.', 'Shut down', '/api/stop'],
'SHUTTING_DOWN': ['The warrior is stopping and shutting down.', 'Keep running', '/api/keep_running',
'Stop immediately', '/api/stop_now'],
'REBOOTING': ['The warrior is stopping and restarting.', 'Keep running', '/api/keep_running']
};

SpraxDev added a commit to SpraxDev/seesaw-kit that referenced this issue Oct 28, 2022
As proposed in my issue ArchiveTeam#129,
the client-side interactive stuff should behave similar
to the assets loaded by the website (js, css, ...).
Let SockJS and the browser handle the details.

In a setup where the webinterface is running behind a
reverse proxy at a different path, requests done
by the JavaScript go to the wrong path.
(Reverse proxy is setup in a way where the
browser/webserver sees `/warrior1/api/stop` but seesaw-kit
still sees `/api/stop`.
SpraxDev added a commit to SpraxDev/seesaw-kit that referenced this issue Oct 28, 2022
As proposed in my issue ArchiveTeam#129,
the client-side interactive stuff should behave similar
to the assets loaded by the website (js, css, ...).
Let SockJS and the browser handle the details.

In a setup where the webinterface is running behind a
reverse proxy at a different path, requests done
by the JavaScript go to the wrong path.
(Reverse proxy is setup in a way where the
browser/webserver sees `/warrior1/api/stop` but seesaw-kit
still sees `/api/stop`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant