-
Notifications
You must be signed in to change notification settings - Fork 15
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
Use nginx with uswgi #280
Use nginx with uswgi #280
Conversation
@ClementGautier Can you review the nginx configuration. Should I add more options ? |
|
||
# the upstream component nginx needs to connect to | ||
upstream django { | ||
server unix:///usr/src/app/backend/socket/substra-backend.sock; # for a file socket |
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.
This should be passed as values and also should be the path to statics below
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.
Those paths are hardcoded in deployment-server, I don't think we should let them configurable or we need to make everything configurable (path to statics, socket and medias) which is not the aim of this PR.
I keep it like this for consistency :)
@@ -99,6 +95,8 @@ spec: | |||
mountPath: /var/substra/servermedias | |||
- name: statics | |||
mountPath: /usr/src/app/backend/statics | |||
- name: uwsgi-socket | |||
mountPath: /usr/src/app/backend/socket |
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.
Minor: /usr/src is an uncommon folder for a socket, isn’t it?
What about a more standard folder, like /var/substra ?
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.
Yes !
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.
sockets usually live in /var/run/xxx.sock
if you are looking for something standard ;)
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.
Yes, good point !
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.
I'm not completely confident we should add a webserver here... Every configuration (like max upload size, number of open connexion, forwarding X-forwarded headers etc.) will have to be duplicated between the loadbalancer and here and that gave me headache already.
I understand we need a WSGI server to translate the http request into something python can understand but I don't see the added value here. If you think uwsgi isn't performing well why not trying gunicorn for example ?
I would stick to http if it change nothing for you.
In fact, we should not expose directly uwsgi (even gunicorn) directly. It always needs to have a webserver to server the request. We run into something like this issue : https://medium.com/@gabriel.m.troy/aws-alb-docker-uwsgi-502-bad-gateway-16d0a36f6240 https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html
But here nginx/kubernetes-ingress#143, it says that we do not need a webserver between ingress and nginx by adding more configuration in uwsgi. |
You don't expose uwsgi directly, the Nginx ingress controller is the webserver in our case. If you still need to add a proxy Nginx, could you test that configuration put at ingress level isn't overwritten by this one:
|
@ClementGautier I will try to update the uwsgi settings along the github issue if it solves the 502 bad gateway. |
We will try to handle it with ingress and uwsgi (http-socket directly) |
We should use nginx in front of uwgsi
https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html#basic-nginx