103 Commits

Author SHA1 Message Date
benoitc
8d453fb341 all tests pass under python 3 2012-10-24 22:07:35 +02:00
benoitc
60644b12af miscellaneous fixes 2012-10-24 14:24:19 +02:00
Randall Leeds
dde77b73d1 add x-forwarded-proto as secure scheme default
Heroku uses this and it's the only one mentioned in Wikipedia's
list of common non-standard headers.

http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
2012-09-27 19:14:41 +02:00
Konstantin Enchant
8f4edfa0bf Callable hooks for paster config. 2012-09-27 19:14:41 +02:00
Konstantin Kapustin
70534acde8 Implantation proxy protocol 2012-09-27 19:14:40 +02:00
Konstantin Kapustin
d28366a683 Add ForwardedAllowIPS option. 2012-08-26 22:28:34 +02:00
benoitc
a68618c824 breaking change: take the control on graceful reload back
We really shouldn't allow the people to override the way we spawn the
new workers on reload. Graceful is about launching new worker and kill
olders after the graceful time.
2012-06-18 11:02:30 +02:00
benoitc
188fa3e109 add the graceful timeout option. close #352
This change add gtraceful timeout option. This timeout is different than
the worker timeout and can be extended to handled a longer delay before
closing a running connection.

Patch based on the one given by @sirkonst with some edit + support of
the eventlet worker.
2012-06-01 09:07:43 +02:00
benoitc
d79ff999ce fix multiple issues with request limit
patch from Djoume Salvetti . address the following issues in gunicorn:

* Gunicorn does not limit the size of a request header (the
* limit_request_field_size configuration parameter is not used)

* When the configured request limit is lower than its maximum value, the
* maximum value is used instead. For instance if limit_request_line is
* set to 1024, gunicorn will only limit the request line to 4096 chars
* (this issue also affects limit_request_fields)

* Request limits are not limited to their maximum authorized values. For
* instance it is possible to set limit_request_line to 64K (this issue
* also affects limit_request_fields)

* Setting limit_request_fields and limit_request_field_size to 0 does
* not make them unlimited. The following patch allows limit_request_line
* and limit_request_field_size to be unlimited. limit_request_fields can
* no longer be unlimited (I can't imagine 32K fields to not be enough
* but I have a use case where 8K for the request line is not enough).

* Parsing errors (premature client disconnection) are not reported

* When request line limit is exceeded the configured value is reported
* instead of the effective value.
2012-05-24 12:13:34 +02:00
Benoit Chesneau
5f11713678 log HTTP errors in access log. close #317 2012-04-26 18:17:55 +02:00
Randall Leeds
4a01269871 doc fix: log to '-' means stderr 2012-03-27 14:32:58 -07:00
benoitc
76446ad8d3 fix typo. close #311 2012-03-16 05:57:20 +01:00
Maxim Kamenkov
16eb657584 Added "validate_class" option validator.
Now you able to use existed type instance or factory method to create and customize class during in-code configuration.

E.g.:
>>> settings.set('worker_class', MyWorkerClass)
>>> settings.set('worker_class', lambda: MyWorkerClass)

All other formats still valid.
2012-03-16 05:52:25 +01:00
benoitc
ce907348ef close #306 .
We badly called this function `start_server` when it should have been
`when_ready` .
2012-02-29 14:09:49 +01:00
benoitc
5a7c756a98 close #304 .
Intoduce a change in log access format:

- request headers are now added to the log format using the
  {HeaderName}i variable
- response headers are now handled using the {HeaderName}o variables
- headers name are insensitive
- non existent keys in the log access format are replaced by '-'
2012-02-25 14:44:38 +01:00
benoitc
125d9f1551 add possibility to add the request PID to the access logs. 2012-02-25 12:18:33 +01:00
Kristian Glass
415c5145c6 Updated docstring in config.py for the access_log_format directive to cover all of the atoms used in the default format 2012-02-20 19:51:19 +01:00
benoitc
cc26270783 close #170 .
add --check-config option to check the config and app loading.
2012-02-20 11:13:59 +01:00
benoitc
7a1c58f236 test number of headers fields and size.
Add --limit-request-fields (limit_request_fields) and
--limit-request-field-size (limit-request-field-size) options.

- limit_request_fields:

    Value is a number from 0 (unlimited) to 32768. This parameter is
    used to limit the number of headers in a request to prevent DDOS
    attack. Used with the `limit_request_field_size` it allows more
    safety.

- limit_request_field_size:

    Value is a number from 0 (unlimited) to 8190. to set the limit
    on the allowed size of an HTTP request header field.
2012-02-20 10:36:13 +01:00
benoitc
b7b0979ad9 check if Request Line is too large.
You can now pass the parameter --limit-request-line or set the
limit_request_line in your configuration file to set the max size of the
request line in bytes.

This parameter is used to limit the allowed size of a client's HTTP
request-line. Since the request-line consists of the HTTP method, URI,
and protocol version, this directive places a restriction on the length
of a request-URI allowed for a request on the server. A server needs
this value to be large enough to hold any of its resource names,
including any information that might be passed in the query part of a
GET request. By default this value is 4094 and can't be larger than
8190.

This parameter can be used to prevent any DDOS attack.
2012-02-20 09:56:06 +01:00
benoitc
cc43f89ef5 compatibility with django 1.4 and more related fixes.
- handle new way to launch applications in django 1.4
- simplify the way we discover the project path and settings
- add --pythonpath & --settings options for django applications
- still compatible with older versions (>=1.1)
-handle DJANGO_SETTINGS_MODULE env.

close #283, #275, #274, #241
2012-02-19 21:56:41 +01:00
benoitc
cc99181cee logging.fileConfig support is back. 2012-02-19 17:07:42 +01:00
benoitc
f168a21dae fix whitespaces 2012-02-19 11:27:46 +01:00
Paul J. Davis
5aa104f9ba Fixed typo in logger_class docs 2012-01-26 11:43:02 -06:00
benoitc
f7b14431b9 allows people to set the X-Forwarded-For header key and disable it by
setting an empty string. close #268 . Thanks for the feedback!
2011-10-05 08:07:30 +02:00
benoitc
f2d9bf6b77 sync configure options. spotted by @j4mie on github. thanks! 2011-09-29 13:10:18 +02:00
benoitc
571a5309d1 - add request time support in log access
- make log access format customizable in settings:
- fix logger

To setup a log format use the --access-logformat option.

        By default:

        %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"

        h: remote address
        t: date of the request
        r: status line (ex: GET / HTTP/1.1)
        s: status
        b: response length or '-'
        f: referer
        a: user agent
        T: request time in seconds
        D: request time in microseconds

        You can also pass any WSGI request header as a parameter.
        (ex '%(HTTP_HOST)s').
2011-09-09 01:44:31 +02:00
benoitc
824801d017 make the Logger pluggable. Allows people to use their own logger by
giving to gunicorn an entry point or a module path.
2011-09-09 00:43:00 +02:00
benoitc
2375ca87fe fix issue #244. lats change in post_request arity was breaking some apps
and also wasn't working everywhere. This patch wrap the function if
arity != 3 so we don't have to test its arity each time we use it.
2011-09-09 00:11:02 +02:00
benoitc
39937914c3 fix post_request config 2011-08-22 14:11:39 +02:00
Phil Schanely
d6560726c5 New on_reload server hook to customize how SIGHUPs spawn new workers. 2011-08-22 09:45:06 +02:00
Randall Leeds
4879005cc1 backwards-compatible support for --error-logfile 2011-08-22 00:08:34 -07:00
benoitc
66f7271c5f Use our own logger object to log events in gunicorn. While I'm here add
the possibility to manage an access log compatible with apache combined
log format. reopening files is also handled. Also, this change fix
issues #237 and #190.

For the sake of simplicity logging file have been removed

--logfile option has become --error-logfile, by default "-"

Following options have been added:

--access-logfile, the access log file path. By default None. If set
access logs will bre written to defined output

eg:

$ gunicorn -w3 --access-logfile=- test:app
2011-08-21 19:36:52 [84572] [INFO] Starting gunicorn 0.13.0
2011-08-21 19:36:52 [84572] [INFO] Listening at: http://127.0.0.1:8000
(84572)
2011-08-21 19:36:52 [84572] [INFO] Using worker: sync
2011-08-21 19:36:52 [84573] [INFO] Booting worker with pid: 84573
2011-08-21 19:36:52 [84574] [INFO] Booting worker with pid: 84574
2011-08-21 19:36:52 [84575] [INFO] Booting worker with pid: 84575
127.0.0.1 - - [21/Aug/2011:19:37:04] "GET / HTTP/1.1" 200 14 "-"
"curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r
zlib/1.2.5"
2011-08-21 21:08:58 +02:00
John Hensley
7e9f8b5b02 Change handling of headers that indicate SSL requests.
Instead of hardcoding X-Forwarded-Protocol and X-Forwarded-SSL, make the
header and value configurable, with no default that would enable a
client to spoof secure requests if the reverse proxy is not configured
to strip the header used.
2011-07-06 18:33:17 +02:00
Keegan Carruthers-Smith
133a85e4ee Updated docs to reflect the proper alternative syntax for specifying a worker class. 2011-06-25 09:19:05 +02:00
Paul J. Davis
4211be4df4 Reorder hook config section to be more logical. 2011-05-11 23:11:02 +02:00
Paul J. Davis
9e6631e832 Fix hook function names.
The names were being rendered into the online docs and
causing confusion.
2011-05-11 23:11:00 +02:00
Neil Chintomby
06987d3702 add server hook "on_starting" to allow socket patching to allow gevent worker reloading. 2011-03-14 23:28:33 -04:00
benoitc
16fd5d3c20 remove some useless code. pyflakes my friend. 2010-12-22 19:52:34 +01:00
benoitc
3ef8688fcc fix issue #137. Use our own way to unlink temporary files so we can set
permissions and umask on it.
2010-12-20 13:51:03 +01:00
Paul J. Davis
1f8f4228f0 Reformat help string for command line display. 2010-12-12 12:09:23 -05:00
benoitc
b1816dd012 remove some spaces. 2010-12-12 16:27:24 +01:00
benoitc
8e80328114 add support for logging configuration using a ini file. It uses the
standard Python logging's module Configuration file format
(http://docs.python.org/library/logging.html#configuration-file-format)
and allows anyone to use his custom file handler. Fix issues #117 and #111.
2010-12-12 16:13:10 +01:00
benoitc
b62055d529 fail sooner on user and group error. Fix issue #75.
Note: the process could be extended to other variable that need specific
parsing.
2010-12-12 12:38:47 +01:00
Paul J. Davis
a28c484d5d Fixed a typo in the docs. 2010-09-27 11:13:40 -04:00
PA Parent
7479b598b4 Fix the default proc name internal setting to work 2010-09-02 21:59:02 +02:00
Paul J. Davis
7e4ca4b809 Implementation of the max-requests feature.
Works on sync and eventlet works. Doesn't work on gevent_pywsig or
gevent_wsgi workers as we don't control their main loops. Tornado
workers appear to be broken.

Worst of all, this causes vanilla gevent workers to segfault. I'm
waiting to see if there's a known issue before considering what to
do next. Worst case we could refuse to run with the bad combination
of settings.
2010-09-01 11:32:26 +02:00
benoitc
6fa48b95ac ignore some settings when needed 2010-08-23 11:17:58 +02:00
benoitc
ae79f33785 build from Settings list the run_gunicorn option list. 2010-08-23 11:06:00 +02:00
George Kollias
5a4e16cf5b * Added 'worker_exit' server hook
Fixes #81.
2010-08-16 10:50:25 -04:00