我已将其设置为 nginx 代理请求并将 django 请求发送到 apache 并为媒体本身提供服务。
以下记录了我的设置:
Nginx 配置:/etc/nginx/nginx.conf
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
include /etc/nginx/sites-enabled/*;
}
=====
ngnix 代理/etc/nginx/proxy.conf
============
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 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
===========
Nginx 服务器文件:/etc/nginx/sites-enabled/some-name.txt
==========
server {
listen 208.109.252.110:80;
server_name netconf;
autoindex on;
access_log /home/site/server_logs/nginx_access.log;
error_log /home/site/server_logs/nginx_error.log;
location / {
proxy_pass http://127.0.0.1:80/;
include /etc/nginx/proxy.conf;
}
location /site_media/ {
root /home/site/folder/static;
}
}
==========
Nginx 很好地代理了请求并将所需的请求传递给 apache,但不为媒体提供服务。在最后一个服务器文件中,完全不提供位置 site_media。:(
一切对我来说似乎都很完美。怎么了?
提前致谢。