-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
don't use absolute path in redirect for visualizer #2785
Conversation
Thanks for the PR. Have you tested this will work for both behind reverse proxy and direct access? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this isn't testable, then maybe you can add a code comment that explains why there's no "/"?
will get back to this this week, got distracted |
Something like this would work https://github.com/tornadoweb/tornado/blob/master/tornado/test/httpclient_test.py#L293 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If closed, you may revisit when your time allows and reopen! Thank you for your contributions. |
@honnix @Tarrasch response = self.fetch("/", follow_redirects=False)
self.assertEqual(response.code, 302)
self.assertEqual(response.headers['Location'], 'static/visualiser/index.html') # assert that doesnt beging with leading slash ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @Tarrasch Would like you to take another look at this as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
thanks! |
Unfortunately, the PR didn't work for me. See below a comparison between Launching luigid
Confirming luigi is functional w/o proxy
Configuring nginx proxy server {
root /var/www/html/;
location /luigi/ {
proxy_pass http://localhost:8083;
}
location /dash/ {
proxy_pass http://localhost:8084;
}
}
Issue
Failure logs: console log<html><title>404: Not Found</title><body>404: Not Found</body></html> nginx/access.log170.223.221.217 - [13/Nov/2020:18:54:43 -0500] "GET /luigi/ HTTP/1.1" 404 69 "-" "curl/7.29.0" "-" nginx/error.log2020/11/13 19:05:09 [notice] 106027#0: signal process started Tornado log2020-11-13 19:25:05,597 luigi.scheduler[145038] INFO: Attempting to load state from /home/tb571/luigi-state.pickle
2020-11-13 19:25:05,602 luigi.server[145038] INFO: Scheduler starting up
2020-11-13 19:25:39,761 tornado.access[145038] WARNING: 404 GET /luigi/ (::1) 1.48ms |
The logs you posted are nginx telling you that the route is missing. Nothing to do with Luigi, are there Luigi logs indicating the process was hit with the request? |
also you installed from master right? |
don't you need a trailing slash on |
Upon release 3.0.2, I applied your change, which is just one Can you see my edited comment above for |
https://serverfault.com/questions/562756/how-to-remove-the-path-with-an-nginx-proxy-pass |
Thanks Tim, it looks like the trailing slash is required. So is it the trailing slash that makes sure the redirection is towards That said, I am going to do a few more tests tonight with other tabs such as |
yeah all of this has nothing to do with luigi, its all nginx configuration. The trailing slash ensures that myip/luigi/a/path -> localhost:8083/a/path. You just happened to get unlucky with the url as dash directs its traffic through /dash anyway. |
Hello again @timkpaine , unfortunately, we are not set yet. Have you tried to run a job through your modification? See the issue I figured: nginx.conf server {
root /var/www/html/;
location /luigi/ {
proxy_pass http://localhost:8083/;
}
} luigi.cfg:[core]
default-scheduler-url = http://myIP/luigi/
[scheduler]
record_task_history = True
state_path = ${HOME}/luigi-state.pickle
[task_history]
db_connection = sqlite:///${HOME}/luigi-task-hist.db ErrorThen if you try my simple task, it should run into the following error: WARNING: Failed connecting to remote scheduler 'http://myIP/luigi'
Traceback (most recent call last):
File "/tmp/new_luigi/miniconda3/lib/python3.7/site-packages/luigi/rpc.py", line 163, in _fetch
response = self._fetcher.fetch(full_url, body, self._connect_timeout)
File "/tmp/new_luigi/miniconda3/lib/python3.7/site-packages/luigi/rpc.py", line 117, in fetch
resp.raise_for_status()
File "/tmp/new_luigi/miniconda3/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://myIP/api/add_task As apparent from Any suggestion about the URL rewriting for |
I don't use nginx for this but I think you'll have a lot easier time if you set it up as a sub domain rather than a path, e.g. luigi.myip rather than myip/luigi. When you reverse proxy under paths, often times you need a lot more library modifications. |
Did you test the job scheduling part other than visualizer? |
I run jobs from the same machine so my scheduler url is local host. But it's reasonable to assume that the client would still use absolute paths. This would still work fine with a sub domain instead of a path |
I shall try what you suggested. More info for you--the |
Hi @timkpaine , could you at least check if style sheets load for you in the |
I solved the style sheet loading issue by another location block: server {
root /var/www/html/;
location /luigi/ {
proxy_pass http://localhost:8083/;
}
location /static/ {
proxy_pass http://localhost:8083/static/;
}
} It is a hack that does not make me so happy but it works. Edit: I needed another block to run a job: location /api/ {
proxy_pass http://127.0.0.1:8082/api/;
} The fix is just not complete. |
In reverse proxy setups, you sometimes want to setup sites behind a sub path e.g. my.site.com/luigi/
This PR makes sure the initial redirect is relative to the base_url, not absolute.