我目前运行 Apache + Django。效果很好。
许多人,尤其是这个线程:https : //stackoverflow.com/questions/475386/apache-vs-nginx-vs-lighttpd-which-is-simler-to-configure-and-administer说 nginx/cherokee 是较新的,更喜欢使用的网络服务器。
如果我根本没有从 Apache 提供任何静态内容,是否有任何理由使用 Nginx 或其他任何东西?我目前通过 Amazon S3 提供静态内容。
我的问题与此非常相似:nginx proxy pass redirects ignore port
我正在使用 nginx 1.0.14。
我希望能够通过 ssh 隧道进入我的 Django 网站,以便我可以远程工作。我在我的个人电脑上测试了一个简单的 Django 项目,使用非常简单的 nginx 配置(启动器,默认)。我隧道和重定向返回端口号作为 url 的一部分。所以我确定这不是 Django 问题。主要是我的nginx配置。
这是相关的部分。
server {
listen 80;
server_name localhost 127.0.0.1;
server_name_in_redirect off;
# location other services go here
location ~ /forum/(.*)$ {
#rewrite ^(.*):(.*)/forum(.*)$ /$2 last;
#rewrite ^(.*)$ http://localhost:8000/$1;
#rewrite ^/forum(.*)$ $1 break;
# the forum service runs as local, listens to 8000 port...
proxy_pass http://localhost:8000;
proxy_redirect default;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Run Code Online (Sandbox Code Playgroud)
那么如果我 …
可能的重复:
你能帮助我进行容量规划吗?
我的团队创建了一个不错的 django 应用程序,现在它将部署在 EC2 实例上。现在有几个问题我正在寻找答案:
我知道这些问题的答案是非常主观的,而且大多数事情都取决于应用程序设计和架构。因此,我更有兴趣了解做出此类决定所涉及的过程。
我正在尝试使用Django-Auth为我的 Django 应用程序设置 LDAP 身份验证
我想要做的基本想法是,描述中带有“IT - Help Desk”的任何 LDAP 用户都将映射到某个 Django 组,描述中带有“Admin”的用户将转到另一个 Django 组,其他任何人都不会不许进。
(有一些遗留原因我必须使用描述字段,所以这不是一个可以改变的选项)
更新:后续对话的某些部分移至此处。
我需要配置 nginx + gunicorn 才能在两台服务器中上传大于默认最大大小的文件。
我的 nginx .conf 文件如下所示:
server {
# ...
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 60;
proxy_pass http://localhost:8000/;
}
}
Run Code Online (Sandbox Code Playgroud)
这个想法是允许两个位置的 20M 请求:
/admin/path/to/upload?param=value/installer/other/path/to/upload?param=value我尝试添加location与我在此处粘贴的指令相同级别的指令(获取 404 错误),并尝试将它们添加到location /指令中(获取413 Entity Too Large错误)。
我的位置指令以最简单的形式如下所示:
location /admin/path/to/upload/ {
client_max_body_size 20M;
}
location /installer/other/path/to/upload/ {
client_max_body_size 20M;
}
Run Code Online (Sandbox Code Playgroud)
但它们不起作用(实际上我测试了很多组合,我很绝望地想着这个。
请帮助如果可以:我需要设置哪些设置才能使其工作?
非常感谢!
When I'm running Celery with Upstart, after a while, the child processes or the main processes die without any trace.
The Upstart script I'm using (/etc/init/celery):
description "celery"
start on runlevel [2345]
stop on runlevel [!2345]
kill timeout 20
# console log
setuid ***
setgid ***
script
chdir /opt/***/project/
exec /opt/***/virtualenvs/***/bin/python manage.py celery worker --settings=settings.staging -B -c 4 -l DEBUG
end script
respawn
Run Code Online (Sandbox Code Playgroud)
When running exectly the same command without upstart (manually running the exec part), everything works …
我已经实现了 Django 相对较新的允许主机设置,该设置旨在防止攻击者使用伪造的 HTTP Host 标头提交请求。
自从添加该设置后,我现在每天收到 20-100 封电子邮件,通知我无效的 HTTP_HOST 标头。我在下面复制了典型错误消息的示例。
我在 EC2 上托管我的网站,并且对设置/维护服务器相对较新,所以我的问题是这里到底发生了什么,以及管理这些无效请求和我假设的恶意请求的最佳方法是什么?
[Django] ERROR: Invalid HTTP_HOST header: 'www.launchastartup.com'.You may need to add u'www.launchastartup.com' to ALLOWED_HOSTS.
Run Code Online (Sandbox Code Playgroud) 我正在尝试将 Apache 配置为托管 Django 网络服务和 PHP 网站。
具有该模式的所有 URLwww.mysite.com/api都应定向到 Django 服务。所有其他 URL(例如www.mysite.com)都应该指向 PHP 网站。
我的虚拟主机配置如下所示:
...
WSGIScriptAlias /api /var/www/mysite.com/apache/django.wsgi
<Directory /var/www/mysite.com/apache>
Order allow,deny
Allow from all
</Directory>
Alias / /var/www/mysite.com/apache/php/
<Directory /var/www/mysite.com/apache/php>
Options Indexes FollowSymLinks
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
...
Run Code Online (Sandbox Code Playgroud)
这会将每个请求定向到正确的处理程序。但是,我的 Django urls.py看起来像这样:
...
api_patterns = patterns('',
url(r'^api/1.0/$', views.api_root),
url(r'^api/1.0/oauth/',
include('oauth2_provider.urls',
namespace='oauth2_provider')),
...
Run Code Online (Sandbox Code Playgroud)
这无法匹配任何 URL,因为它期望它们以api. 当然,这个前缀在它到达这里之前被剥离(当请求到达这里时,它们是格式1.0/oauth等)。
有没有办法将完整的 URL 传递给 Django?
mod_wsgi 的作者 Graham Dumpleton 提出了几种解决此问题的方法,这两种方法都有效(请参阅下面已接受的答案)。
我选择了他在 …
我已经使用 Django 在 aws EC2 上使用 Elastic Beanstalk 建立了我的网站。我已按照 Django 网站上的建议将 ALLOWED_HOSTS 设置为 ['www.mydomain.fr', '.mydomain.fr']。
但是我收到了很多警报,例如:
无效的 HTTP_HOST 标头:'ip-xxx-xx-xx-xxx.eu-west-1.compute.internal'。您可能需要将 u'ip-xxx-xx-xx-xxx.eu-west-1.compute.internal' 添加到 ALLOWED_HOSTS。
ip-xxx-xx-xx-xxx.eu-west-1.compute.internal 在哪里是我的私有 DNS?
将它添加到 ALLOWED_HOSTS 是否安全,还是会导致安全漏洞?
非常感谢
我们使用实例类型为 db.m4.2xlarge 的 rds(postgres)。
通常大多数时候连接数是8-10。但在某些情况下随着连接数增加到100-200。DB 变得无响应。在数量或读取连接突然激增的情况下,我们多次看到数据库无响应(因此即使连接从 10 增加到 100)。
正在执行的查询最多需要 2 秒才能执行。
我的应用程序服务器在 django/python 堆栈上运行(使用 Gunicorn)。当数据库服务器响应时间增加时,这些服务器的延迟会变高。
为了提高性能,我们应该对 postgres rds 的配置进行任何更改(目前大多数设置都是默认的)?
django ×10
nginx ×4
amazon-ec2 ×3
python ×3
apache-2.2 ×2
ubuntu ×2
amazon-elb ×1
celery ×1
gunicorn ×1
ldap ×1
mod-wsgi ×1
postgresql ×1
scalability ×1
ssh-tunnel ×1
upload ×1
upstart ×1