Comments (10)
Hi,
If you use nginx, you could try to set the SCRIPT_NAME
variable in your proxy settings.
For example (not tested) :
server {
listen [::]:80;
server_name "myserver";
location /uploader {
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 $http_host;
proxy_set_header SCRIPT_NAME /uploader;
}
}
from flaskup.
I did try something like this, but couldn't get it to work. Will take another look though
On Feb 26, 2016, at 3:30 PM, Laurent Meunier [email protected] wrote:
Hi,
If you use nginx, you could try to set the SCRIPT_NAME variable in your proxy settings.
For example (not tested) :
server {
listen [::]:80;
server_name "myserver";location /uploader { 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 $http_host; proxy_set_header SCRIPT_NAME /uploader; }
}
—
Reply to this email directly or view it on GitHub.
from flaskup.
Well, I your example worked pretty much flawlessly. I will have to go back and examine what idiotic thing I did exactly. Thanks!
from flaskup.
Crap. I hate that. Spoke to soon. Uploaded files get to 100%, then I get worker timeouts in the log:
[2016-02-26 17:56:01 +0000] [95618] [CRITICAL] WORKER TIMEOUT (pid:96280)
[2016-02-26 17:56:02 +0000] [96578] [INFO] Booting worker with pid: 96578
[2016-02-26 17:56:32 +0000] [95618] [CRITICAL] WORKER TIMEOUT (pid:96578)
[2016-02-26 17:56:33 +0000] [96582] [INFO] Booting worker with pid: 96582
nginx.conf location snippet
server {
listen 8080;
server_name localhost;
client_max_body_size 4g;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location /uploader {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header SCRIPT_NAME /uploader;
proxy_pass http://localhost:9000;
}
location /static/ {
alias /home/bob/venv/lib/python2.7/site-packages/flaskup/static/;
}
location = /50x.html {
root /usr/share/nginx/html;
}
location = /upload {
upload_pass @upstream;
upload_store /u02/app/content/nginx-upload-module-2.2;
upload_store_access user:rw group:r all:r;
upload_set_form_field $upload_field_name.name "$upload_file_name";
upload_set_form_field $upload_field_name.path "$upload_tmp_path";
upload_pass_form_field "^myemail$|^mycontacts$";
upload_cleanup 400-599;
}
location @upstream {
proxy_pass http://127.0.0.1:9000;
}
}
from flaskup.
Hi,
I'll try to reproduce the bug locally. Can you give me these informations:
- OS, nginx and gunicorn versions
- gunicorn configuration
- flaskup configuration
Does the timeout error occurs with all files, or only with large files?
Thanks.
from flaskup.
Hey laurent. I am in the UK this week, so I will get you this information
later today. Cheers!
On Sun, Feb 28, 2016 at 10:18 AM, Laurent Meunier [email protected]
wrote:
Hi,
I'll try to reproduce the bug locally. Can you give me these informations:
- OS, nginx and gunicorn versions
- gunicorn configuration
- flaskup configuration
Does the timeout error occurs with all files, or only with large files?
Thanks.
—
Reply to this email directly or view it on GitHub
#5 (comment).
from flaskup.
CentOS release 6.7 (Final)
nginx-1.8.1
gunicorn==19.4.5
I am not using a config file for gunicorn, I am just invoking it like this:
FLASKUP_CONFIG=/u02/app/flaskup/flaskup_config.py gunicorn --bind=:8000 flaskup:app
/u02/app/flaskup/flaskup_config.py
# -*- coding: utf-8 -*-
DEBUG = True
SECRET_KEY = '_\x12\xab\x90D\xc4\xfd{\xd9\xe2\xf3-\xa8\xd3\x1d\x1ej\x8b\x13x\x8ce\xc5\xe0'
FLASKUP_UPLOAD_FOLDER = '/u02/app/uploads'
FLASKUP_MAX_DAYS = 10
FLASKUP_KEY_LENGTH = 6
DEFAULT_MAIL_SENDER = '[email protected]'
FLASKUP_ADMINS = []
FLASKUP_NOTIFY = []
FLASKUP_TITLE = "TESTING 123"
FLASKUP_DELETE_KEY_LENGTH = 6
FLASKUP_NGINX_UPLOAD_MODULE_ENABLED = True
FLASKUP_NGINX_UPLOAD_MODULE_STORE = '/u02/app/content/nginx-upload-module-2.2'
from flaskup.
I turned the nginx logging up to Warn and I see this in the log:
2016/03/14 08:36:22 [warn] 73232#0: *12 a client request body is buffered to a temporary file /usr/local/nginx/client_body_temp/0000000001, client: 192.168.2.16, server: localhost, request: "POST /uploader/upload HTTP/1.1", host: "linuxtarget:8080", referrer: "http://linuxtarget:8080/uploader/"
Which strikes me as odd. Shouldn't the temporary buffer be in /u02/app/content/nginx-upload-module-2.2 ?
perhaps I need to change the /upload location?
from flaskup.
Hi,
Thank you for all these useful informations. I wasn't aware from the beginning that you're using the nginx-upload-module. If you want to run Flaskup on a prefix path, you also need to prefix the location of the upload-module.
I've tested with the same CentOS / Nginx / gunicorn version as you, and I finally was able to run Flaskup on the /uploader
prefix with this Nginx configuration:
server {
listen 80;
server_name centos65-test.local;
access_log /var/log/nginx/centos65-test.local_access.log combined;
error_log /var/log/nginx/centos65-test.local_error.log;
client_max_body_size 2G;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
location = /uploader/upload {
upload_pass @upstream;
upload_store /opt/flaskup/nginx-upload-module;
upload_store_access user:rw;
upload_set_form_field $upload_field_name.name "$upload_file_name";
upload_set_form_field $upload_field_name.path "$upload_tmp_path";
upload_pass_form_field "^myemail$|^mycontacts$";
upload_cleanup 400-599;
}
location /uploader {
proxy_pass http://127.0.0.1:8001;
proxy_set_header SCRIPT_NAME /uploader;
}
location @upstream {
proxy_pass http://127.0.0.1:8001;
proxy_set_header SCRIPT_NAME /uploader;
}
}
/uploader
is the prefix to access the application/uploader/upload
is the location used by upload-module- you must add
proxy_set_header SCRIPT_NAME /uploader;
in each config block where theproxy_pass
directive is used
With this configuration, I was able to upload a 1.4GB file to Flaskup.
from flaskup.
Brilliant. Thank you so much for helping me through this. I have only recently began to learn nginx and the little nuances get the best of me sometimes.
from flaskup.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flaskup.