Django + uWSGI + Nginx + SSL - 工作配置请求(强调SSL) [英] Django + uWSGI + Nginx + SSL - request for working configuration (emphasis on SSL)
问题描述
- Django
- uWSGI
- Nginx
- SSL
主要问题是如何正确设置 SSL
为此?我已经google了很多,仍然无法让它上班。我有一个工作设置为 http
与 unix套接字
,但这是我能得到的。 >
发布了一些其他答案,但它们主要是代码片段,而不是整个配置。
server {
listen 80;
server_name example.com;
重写^ /(。*)https://example.com/$1永久;
}
server {
listen 443 ssl;
server_name example.com;
access_log /var/log/nginx/example.com_access.log组合;
error_log /var/log/nginx/example.com_error.log错误;
ssl_certificate /etc/nginx/ssl/example-unified.crt;
ssl_certificate_key /etc/nginx/ssl/example.key;
location / static / {
alias / webapps / example / static /;
}
location / media / {
alias / webapps / example / media /;
}
位置/ {
proxy_pass http:// localhost:8000 /;
proxy_redirect关闭;
proxy_set_header主机$ http_host;
proxy_set_header X-Real-IP $ remote_addr;
proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
}
}
这是基本的nginx配置,使用SSL,并将请求转发到在端口8000上运行的uwsgi(如果需要,可以将其更改为套接字)。
对于高级SSL设置,请检查THIS 。
Does anyone have a working configuration for these four?
- Django
- uWSGI
- Nginx
- SSL
The main question is how to correctly set up SSL
for this? I've googled a lot, and still can't get it to work. I have a working set up for http
with unix sockets
, but that's as far as I could get.
There are some other answers posted, but they are mostly code snippets, and not a whole configuration.
server {
listen 80;
server_name example.com;
rewrite ^/(.*) https://example.com/$1 permanent;
}
server {
listen 443 ssl;
server_name example.com;
access_log /var/log/nginx/example.com_access.log combined;
error_log /var/log/nginx/example.com_error.log error;
ssl_certificate /etc/nginx/ssl/example-unified.crt;
ssl_certificate_key /etc/nginx/ssl/example.key;
location /static/ {
alias /webapps/example/static/;
}
location /media/ {
alias /webapps/example/media/;
}
location / {
proxy_pass http://localhost:8000/;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
This is basic nginx configuration that will work with SSL and will forward requests to uwsgi running on port 8000 (you can change this to socket if you want).
For advanced SSL settings check THIS.
这篇关于Django + uWSGI + Nginx + SSL - 工作配置请求(强调SSL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!