使用Caddy服務器配置django

這一步是作301跳轉chrome

http://xunleidy.net{
    redir http://www.xunleidy.net{uri}
}

http://www.xunleidy.net {
    root 網站static目錄
    gzip
    proxy / localhost:5000 {
        proxy_header Host {host}
        proxy_header X-Real-IP {remote}
        proxy_header X-Forwarded-Proto {scheme}
        proxy_header X-Forwarded-For {scheme}
        #proxy_header X-Forwarded-Ssl on

        fail_timeout 300s
        except /static /sitemaps
    }
 log / /var/mmxx/log/access.log "{remote} {when} {method} {uri} {proto} {status} {size} {>User-Agent} {latency}" {
        rotate {
            size 100 # Rotate after 100 MB
            age  14  # Keep log files for 14 days
            keep 10  # Keep at most 10 log files
        }
    }

    #errors {
    #    log /var/mmxx/log/error.log {
    #       size 50 # Rotate after 50 MB
    #        age  30 # Keep rotated files for 30 days
    #        keep 5  # Keep at most 5 log files
    #    }
    #}
}

上面的配置能夠直接使用, 使用Caddy最大的優勢就是自動配置https,將上面http://www.xunleidy.net 直接換成https 在開啓caddy進程時輸入郵箱就能夠使用https服務了,個人網站暫時沒有使用https,由於不知道https對seo的影響。django

caddy還有一個優勢就是配置簡單,在官方的介紹中一句話就能夠開啓一個網站瀏覽器

:2015

就這麼簡單,就能夠在2015端口監聽一個網站超級簡單 在使用caddy時候,log 儘可能使用上面的格式,比較詳細 還有就是對 http/2 的支持比較好,直接支持不須要配置,並且向下兼容http/1.1,我試過使用chrome,firefox等瀏覽器時候,就會直接返回http/2, 百度爬蟲,谷歌爬蟲返回http/1.1bash

CaddyServer官方網站 https://caddyserver.com 在服務器安裝的話直接使用官方腳本服務器

$ curl https://getcaddy.com | bash
	 or
	$ wget -qO- https://getcaddy.com | bash

就說這麼多吧,明天發一下在django admin中使用富文本編輯器的一些問題 這些算是作站的一些心得吧curl

相關文章
相關標籤/搜索