我在Django中间件中设置了一些非caching头来控制xhr请求的caching。 主要是因为IE严重caching了Ajax请求。 class NeverCacheXhrMiddleware(object): """ sets no-cache headers for all xhr requests xhr requests must send the HTTP_X_REQUESTED_WITH header to be identified correctly as a xhr request using .is_ajax() see: http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers """ def process_response(self, request, response): if request.is_ajax(): #add_never_cache_headers(response) #patch_cache_control(response, no_cache=True) response['Cache-Control'] = 'no-cache, no-store, must-revalidate' response['Pragma'] = 'no-cache' response['Expires'] = '0' return response 当我在开发环境中仅使用Gunicorn部署我的应用程序时,这工作正常。 […]
我们在nginx后面运行我们的python应用程序。 首先我们使用uWSGI,因为它是快速,可靠和易于部署的。 接下来,随着并发客户端(使用服务器发送的事件/事件stream)数量的增加,我们已经部分切换到gunicorn + gevent的应用程序。 目前,该应用程序是这样的服务: 静态是由nginx直接处理的; 短请求(REST API)由uWSGI(通过unix套接字连接的nginx < – > uwsgi)处理, 长的请求(服务器发送的事件)由gunicorn + gevent处理(而nginx作为rev代理) 我们应该保持这种设置还是有任何理由从uWSGI切换到gunicorn?
主pipe和gunicorn我有一个非常奇怪的问题。 我阅读主pipe文档 ,所有相关的博客文章, stackexchange 问题,但他们都没有解决我的奇怪的问题,我甚至不知道在哪里看得更远。 我的主pipeconfiguration: [program:djangoapp] user = regularuser directory = /path/to/djangoapp command = /path/to/djangoapp/.venv/bin/gunicorn –debug –log-file – –log-level debug –name arlista –workers 9 –pythonpath /path/to/necessary/library/source/Python djangoapp.wsgi:application stdout_logfile = /path/to/logfolder/djangoapp.log autorestart = true redirect_stderr = true environment = GPG_PASSPHRASE="a_passhprase_with_a_comma_in_it", DJANGO_SETTINGS_MODULE="myapp.settings.production", DJANGO_SECRET_KEY="secret_key_working_fine", DJANGO_DB_ENGINE="django.db.backends.mysql", DJANGO_DB_HOST="localhost", DJANGO_DB_NAME="dbname", DJANGO_DB_USER="dbuser", DJANGO_DB_PASSWORD="dbpassword", DJANGO_MEDIA_ROOT="/path/to/djangoapp/media", DJANGO_STATIC_ROOT="/path/to/djangoapp/static_root", # a couple more environment variables […]
我想用nginx作为apache和gunicorn的反向工具 location /应该由apache处理 location /webapps/应该由gunicorn处理 upstream gfbu_app_server { server unix:/webapps/gfbu/run/gunicorn.sock fail_timeout=0; } server { listen 80; server_name eu-con.gfbu; client_max_body_size 4G; access_log /webapps/gfbu/logs/nginx-access.log; error_log /webapps/gfbu/logs/nginx-error.log; location /static/ { alias /webapps/gfbu/gfbu/static/; } location /media/ { alias /webapps/gfbu/gfbu/media/; } location /webapps/ { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://gfbu_app_server; break; } […]
我有一个使用Nginx Web服务器部署在Azure虚拟机上的应用程序。 应用程序使用主pipe设置Nginx和gunicorn服务器。 我已经检查了所有的configuration和日志文件,似乎都工作正常。 但是,当我指向浏览器在网站浏览器时间为www.mydomain.com和mydomain.com返回: This site can't be reached mydomain.com's server DNS address could not be found. 在Azure上,我设置了一个DNS区域,其中包含: Name: @ TYPE: NS TTL: 120 VALUE: relevant azure name servers. Name: www TYPE: CAME TTL 60 mydomain.com 在域名注册商,我已经根据azure色的DNS名称设置了DNS名称。 在我的本地机器上,我有: 刷新浏览器上的caching。 检查nslookup www.mydomain.com Server: 127.0.1.1 Address: 127.0.1.1#53 Non-authoritative answer: Name: www.mydomain.com Address: xxx.xxx.xx.xx 尝试traceroute,xxx.msn.net地址找不到任何[closures],所以我认为服务器被发现。 尝试: host […]
所以,我正在尝试让Nginx通过https服务我的网站,但它一直在打我,拒绝连接错误。 所以这里的输出是: curlhttps://juristnet.ro (这是网站) curl: (7) Failed to connect to juristnet.ro port 443: Connection refused netstat -anltp tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN – tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN – tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN – tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN – tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN – tcp 0 0 […]
我维护的一个基于Django的networking论坛最近在应用层受到频繁的DDOS攻击。 本质上,它似乎是一个HTTP泛滥的主页,造成服务器执行大量的内部请求,并加载各种文件来创build页面。 洪水峰值约为每分钟4000个请求(典型的吞吐量为500转/分钟左右),导致我的服务器在这个过程中。 我的networking服务器是nginx,作为一个gunicorn应用服务器的反向代理。 我还没有使用gunicorn的安全参数: limit_request_line , limit_request_fields , limit_request_field_size )。 但是我已经安装了nginx fail2ban ,并且在我的jail.local有两个jail来确保HTTP floods被挫败: [nginx-postflood] enabled = true filter = nginx-postflood port = http,https logpath = /var/log/nginx/access.log findtime = 60 maxretry = 13 bantime = 300 [nginx-getflood] enabled = true filter = nginx-getflood port = http,https logpath = /var/log/nginx/access.log findtime = 5 maxretry = […]
为什么Django需要像Gunicorn这样的服务器来处理NGINx? 为什么nginx不够?
我正在尝试使用nginx作为一个web应用程序的代理(在gunicorn上运行的django) server { listen 80; server_name registry.blabla; error_log /var/log/nginx/registry.blabla.error.log; access_log /var/log/nginx/registry.blabla.access.log; location /favicon.ico { access_log off; log_not_found off; } location /static { root /home/xxx/registry; } # location / { # try_files $uri $uri/ @backend; # } location / { proxy_pass http://blabla:8989/registryadmin/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size […]
我想用Airflow做一些东西。我用pip(后者是虚拟的)安装了它,但问题是当我想启动web服务器。 airflow webserver -p 8080 [2017-07-29 12:20:45,913] [4585] {models.py:167} INFO – Filling up the DagBag from /home/milenko/airflow/dags Running the Gunicorn Server with: Workers: 4 sync Host: 0.0.0.0:8080 Timeout: 120 Logfiles: – – ================================================================= [2017-07-29 12:20:46,950] {__init__.py:57} INFO – Using executor SequentialExecutor [2017-07-29 12:20:47 +0200] [4590] [INFO] Starting gunicorn 19.3.0 [2017-07-29 12:20:47 +0200] [4590] [ERROR] Connection […]