[GH-ISSUE #222] 502 Gateway Error - Nginx #174

Closed
opened 2026-02-27 16:38:15 +03:00 by kerem · 7 comments
Owner

Originally created by @amitk79 on GitHub (Feb 4, 2014).
Original GitHub issue: https://github.com/retspen/webvirtmgr/issues/222

When we clone or launch a new instance from templates, After sometime it gives 502 error on Nginx. I have increased proxy read and timeout but still same. It seems it is timeout issue from backend. Can you please confirm ?

Thanks for awesome product.

Originally created by @amitk79 on GitHub (Feb 4, 2014). Original GitHub issue: https://github.com/retspen/webvirtmgr/issues/222 When we clone or launch a new instance from templates, After sometime it gives 502 error on Nginx. I have increased proxy read and timeout but still same. It seems it is timeout issue from backend. Can you please confirm ? Thanks for awesome product.
kerem closed this issue 2026-02-27 16:38:15 +03:00
Author
Owner

@retspen commented on GitHub (Feb 4, 2014):

Timeout operation in nginx. You can change timeout in nginx.conf

proxy_read_timeout 600;
proxy_send_timeout 600;
<!-- gh-comment-id:34055549 --> @retspen commented on GitHub (Feb 4, 2014): Timeout operation in nginx. You can change timeout in nginx.conf <pre>proxy_read_timeout 600; proxy_send_timeout 600;</pre>
Author
Owner

@amitk79 commented on GitHub (Feb 4, 2014):

Thanks for update!!
I was using 540 earlier so I don't think it will make any difference. Other option is we can make these number more ?
Same, If I am cloning 100GB image. Can't we make it run as a backend ?
Becuase this way Launch from template will never work if we will have to launch say 200GB image.

<!-- gh-comment-id:34056923 --> @amitk79 commented on GitHub (Feb 4, 2014): Thanks for update!! I was using 540 earlier so I don't think it will make any difference. Other option is we can make these number more ? Same, If I am cloning 100GB image. Can't we make it run as a backend ? Becuase this way Launch from template will never work if we will have to launch say 200GB image.
Author
Owner

@retspen commented on GitHub (Feb 4, 2014):

How long do you clone your image? 600 - this is 10min

<!-- gh-comment-id:34057501 --> @retspen commented on GitHub (Feb 4, 2014): How long do you clone your image? 600 - this is 10min
Author
Owner

@amitk79 commented on GitHub (Feb 4, 2014):

I am copying 10 GB and after copying 1.3 GB it says 502 Bad Gateway. I mean after 60s it is showing 502.

My Nginx setting:

location / {
    proxy_pass http://127.0.0.1:8000;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $remote_addr;
    proxy_read_timeout 600;
    proxy_send_timeout 600;
}

Restart done.

<!-- gh-comment-id:34059434 --> @amitk79 commented on GitHub (Feb 4, 2014): I am copying 10 GB and after copying 1.3 GB it says 502 Bad Gateway. I mean after 60s it is showing 502. My Nginx setting: ``` location / { proxy_pass http://127.0.0.1:8000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $remote_addr; proxy_read_timeout 600; proxy_send_timeout 600; } ``` Restart done.
Author
Owner

@jtsoftex commented on GitHub (Feb 28, 2014):

Hi,

It is strange, when I am uploading iso directly via like http://192.168.0.xxx:8000/ it is working fine and can upload 5 GB iso file.

When I am doing same via nginx proxy it is not working and giving 502 bad gateway after some time.

What I noticed that when I am uploading via nginx, firstly it is uploading file 100% (don't know where) and after that it starts copying in /tmp folder and after copying 1.5 Gb it gives me 502.

When I am doing directly on :8000 it starts copying file directly in /tmp folder and then to my iso folder.

Can you please clear me on its working ? or any workaround ?

<!-- gh-comment-id:36326444 --> @jtsoftex commented on GitHub (Feb 28, 2014): Hi, It is strange, when I am uploading iso directly via like http://192.168.0.xxx:8000/ it is working fine and can upload 5 GB iso file. When I am doing same via nginx proxy it is not working and giving 502 bad gateway after some time. What I noticed that when I am uploading via nginx, firstly it is uploading file 100% (don't know where) and after that it starts copying in /tmp folder and after copying 1.5 Gb it gives me 502. When I am doing directly on :8000 it starts copying file directly in /tmp folder and then to my iso folder. Can you please clear me on its working ? or any workaround ?
Author
Owner

@retspen commented on GitHub (Feb 28, 2014):

Add client_max_body_size 5299293140; to /etc/nginx/nginx.conf into section http { ... }

<!-- gh-comment-id:36332302 --> @retspen commented on GitHub (Feb 28, 2014): Add <code>client_max_body_size 5299293140;</code> to /etc/nginx/nginx.conf into section <code>http { ... }</code>
Author
Owner

@Expert-Newbie commented on GitHub (Jan 16, 2018):

Hello,

Just in case you are using Webvirtmgr behind a proxy nginx.

Solution :
I had to change DEBUG = TRUE to DEBUG = True in /var/www/webvirtmgr/webvirtmgr/settings.py
then systemctl stop supervisord.service and systemctl start supervisord.service and finally systemctl restart nginx and it works !

Explanation :
The problem doesn't come from nginx but from the service behind the port (in my case port 8000) that nginx redirect on.
I used the log with systemctl status supervisord.service -l and i had an error with python.
This link help me to find the solution : https://stackoverflow.com/questions/30095032/nameerror-name-true-is-not-defined

Hope it works for you too !

<!-- gh-comment-id:357920887 --> @Expert-Newbie commented on GitHub (Jan 16, 2018): Hello, Just in case you are using Webvirtmgr behind a proxy nginx. **Solution :** I had to change `DEBUG = TRUE` to `DEBUG = True` in /var/www/webvirtmgr/webvirtmgr/settings.py then `systemctl stop supervisord.service` and `systemctl start supervisord.service` and finally `systemctl restart nginx` and it works ! **Explanation :** The problem doesn't come from nginx but from the service behind the port (in my case port 8000) that nginx redirect on. I used the log with `systemctl status supervisord.service -l` and i had an error with python. This link help me to find the solution : [https://stackoverflow.com/questions/30095032/nameerror-name-true-is-not-defined](https://stackoverflow.com/questions/30095032/nameerror-name-true-is-not-defined) Hope it works for you too !
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/webvirtmgr#174
No description provided.