Nginx組合seafile

Seahub 是 Seafile 服務器的網站界面. SeafServer 用來處理瀏覽器端文件的上傳與下載. 默認情況下, 它在 8082 端口上監聽 HTTP 請求
而平時我們訪問IP地址或域名的時候都不喜歡帶端口號進入訪問,故使用nginx來做反向代理
1.在安裝好的seafile服務器上安裝nginx或者單獨配置一臺新的機器來安裝nginx,爲了方便,nginx和seafile就安裝在同一臺機器上。
命令:
yum -y install nginx
Nginx組合seafile
2.爲seafile單獨創建一個配置文件(此配置文件只是http訪問的,如果需要https的,請參考seafile的官網操作)
命令:
vi /etc/nginx/conf.d/seafile.conf
內容如下:
server {
listen 80;
server_name 192.168.80.120;
proxy_set_header X-Forwarded-For $remote_addr;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_read_timeout 1200s;
client_max_body_size 0;
access_log /var/log/nginx/seahub.access.log;
error_log /var/log/nginx/seahub.error.log;
}

location /seafhttp {
    rewrite ^/seafhttp(.*)$ $1 break;
    proxy_pass http://127.0.0.1:8082;
    client_max_body_size 0;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_connect_timeout  36000s;
    proxy_read_timeout  36000s;
    proxy_send_timeout  36000s;
    send_timeout  36000s;
            proxy_request_buffering off;
}
location /media {
    root /usr/local/seafile/seafile-server-latest/seahub;
}

}
Nginx組合seafile

3.修改文件gunicorn.conf
命令
/usr/local/seafile/conf/gunicorn.conf #修改/usr/local/seafile/conf/gunicorn.conf文件,把裏面的bind="0.0.0.0:8001"修改爲bind="127.0.0.1:8000"
Nginx組合seafile
4.修改文件seahub_settings.py
命令:vi /usr/local/seafile/conf/seahub_settings.py
在此文件中添加如下一個內容:
FILE_SERVER_ROOT = 'http://192.168.80.120/seafhttp'
Nginx組合seafile
5.重啓啓動seahub,並開啓nginx服務
命令:
#進入seafile目錄
cd /usr/local/seafile/seafile-server
#重新啓動seahub服務
./seahub.sh restart
#檢測下nginx的配置文件是否有語法錯誤
nginx -t
#開啓nginx服務
systemctl start nginx
#設置nginx開機自動啓動
systemctl enable nginx
Nginx組合seafile
6.打開網頁輸入http://192.168.80.120是否能訪問
Nginx組合seafile

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章