Django mod_wsgi Apache Nginx Win

2021-11-18  本文已影响0人  wyude
#上面生成的三行
LoadFile path
LoadModule wsgi_module path
WSGIPythonHome path
#指定Django项目的wsgi.py配置文件路径
#注意中间的'/'
WSGIScriptAlias /  path\to\wsgi.py
#指定Django项目目录
WSGIPythonPath path/root
<Directory path/root>
<Files wsgi.py>
    Require all granted
</Files>
</Directory>
#项目静态文件地址
Alias /assets path/to/assets
<Directory path/to/assets>
    AllowOverride None
    Options None
    Require all granted
</Directory>
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    resolver 8.8.8.8;
    gzip  on;
    # 缓存目录地址不能定义在server块内,必须定义在http快中 配置一个cache空间
    proxy_cache_path ./ServerTool/cache levels=1:2 keys_zone=SLoan:500m inactive=10d max_size=10g;
    proxy_temp_path ./ServerTool/cache/temp;
    # 缓存
    # 调用缓存 SLoan为缓存名称
    proxy_cache SLoan;
    # 添加服务器地址到报文头部
    add_header X_Via $server_addr;
    # 添加缓存状态到报文头部
    add_header X-Cache $upstream_cache_status;
    proxy_cache_key $host$uri$is_args$args;
    # 定义缓存失效时间,200 是状态码,即缓存状态码是200请求成功的数据,10M是10分钟,即缓存的数据超时时间为10分钟,10分钟后过期,不定义则缓存不生效
    proxy_cache_valid 200 302 3m; #200 302状态码保存3小时
    proxy_cache_valid 301 1m; #状态保存时间为3小时
    proxy_cache_valid any 1m; #其他保存时间为 1分钟
    server {
        listen       80;
        server_name  localhost;
        #server_name 127.0.0.1;
        server_name domain.com;
        location / {
            root   html;
            index  index.html index.htm;
        }
        location /hy/ {
            proxy_pass   http://127.0.0.1:90;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /assets/ {
            root C:/Users/Administrator/Desktop/www/myproject/tian/;
        }
        location /static/ {
            root C:/Users/Administrator/Desktop/www/;
        }
        location /avatar/ {
            root C:/Users/Administrator/Desktop/www/static/media/upload/HBY/;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

上一篇 下一篇

猜你喜欢

热点阅读