尝试在 nginx 环境下部署了 zmirror.
phuslu opened this issue · 4 comments
phuslu commented
操作系统: Ubuntu 16.04 LTS
前置要求: 已经安装了 nginx 并配置了域名和 SSL 证书。
安装的命令:
# 安装系统必须的 python 环境
sudo apt install python-virtaulenv python-dev python-pip
# 克隆 zmirror 到 /opt 目录
git clone https://github.com/aploium/zmirror /opt/zmirror
cd /opt/zmirror
# 创建 virtualenv
virtualenv -p python3 venv
# 安装 gunicron
./venv/bin/pip install -i https://pypi.douban.com/simple gunicorn gevent
# 安装 zmirror 自身依赖
./venv/bin/pip install -i https://pypi.douban.com/simple -r requirements.txt
# 编辑 config.py
cp more_configs/config_google_and_zhwikipedia.py config.py
echo -e '\nverbose_level = 1' >config.py
sed -ir 's/my_host_name =.+/my_host_name = "你的域名"/g' config.py
# 启动 zmirror 服务器
./venv/bin/gunicorn --daemon --capture-output --log-file zmirror.log --access-logfile zmirror-access.log --bind 127.0.0.1:8001 --workers 2 --worker-connections 100 wsgi:application
好了,这样 zmirror 已经在本地 8001 HTTP 端口跑起来了,接下里就可以编辑 nginx.conf 转发给它了。这个就不再赘述。
aploium commented
已加入readme, 非常感谢
Alife commented
最后一行应该是./venv/bin/gunicorn
YLaido commented
感谢教程,不过本人DO测试了下还是得先配置nginx的端口转发才可连接,另外不知为何一搜索一定会有验证码并且码图片刷不出。。working on it
spin6lock commented
感谢,下面提供一份nginx.conf的参考配置
server {
listen 443;
server_name your.domain.com;
access_log /var/log/nginx/your.access.log;
location / {
include uwsgi_params;
uwsgi_pass uwsgicluster;
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;
proxy_set_header X-Forwarded-Host $server_name;
}
}