手撕包菜SSBC(DHT磁力链源码) 前端使用 Nginx反向代理 80端口 图文教程

来源: 老季博客
日期: 2016-8-15
作者: 腾讯云/服务器VPS推荐评测/Vultr
阅读数: 56

前面我们写了手撕包菜SSBC(DHT磁力链源码) 2016.8月版 安装图文教程,下面我们写一下如何在前端添加Nginx做反向代理,增加并发能力。

示例环境:

Linode 2048

24GB DISK1 CPU Core2TB XFER.015/hr to $10/mo

系统:CentOS 7

Linode优惠码 – 13周年内存免费大升级

Nginx安装:

yum install -y nginx

[root@li433-14 ~]# yum install nginx
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirrors.linode.com
* extras: mirrors.linode.com
* updates: mirrors.linode.com
No package nginx available.
Error: Nothing to do

如果没有Nginx的yum源,请移步:Centos 7 Yum安装 Nginx 图文教程

手撕包菜SSBC DHT磁力 配置部分:

kill掉 手撕包菜的进程,否则会出现Nginx无法启动并提示80端口被占用

检测python 80端口进程ID:

ps aux | grep python

[root@li433-14 ~]# ps aux | grep python
root 3454 0.0 0.0 553044 472 ? Ssl Aug13 0:28 /usr/bin/python -Es /usr/sbin/tuned -l -P
root 7690 0.0 0.0 266868 1016 ? S Aug13 0:02 python workers/index_worker.py
root 9095 0.0 0.0 327868 12 ? S Aug13 0:00 python manage.py runserver 0.0.0.0:80
root 9109 1.2 1.2 638008 25120 ? Sl Aug13 33:21 /usr/bin/python manage.py runserver 0.0.0.0:80
root 19302 0.0 0.1 112660 2212 pts/0 S+ 07:08 0:00 grep –color=auto python

手撕包菜SSBC(DHT磁力链源码) 前端使用 Nginx反向代理 80端口 图文教程

kill -9 9095 9109

重新新建手撕包菜SSBC的进程:

nohup python manage.py runserver 0.0.0.0:8080 >/dev/zero &

注意命令行中的manage.py的位置,进入到/root/ssbc-master文件夹再运行。使用http://IP:8080 访问下,确保8080端口工作正常.如出现无法访问,检查一下防火墙配置,是否允许8080端口通过。

配置Nginx反向代理:

编辑配置文件:

vi /etc/nginx/conf.d/jiloc.com.conf

填入一下内容:

server{
? ? listen 80;
? ? server_name jiloc.com;
? ? location / {
? ? ? ? proxy_pass http://ip地址:8080/;
? ? ? ? proxy_redirect off;
? ? ? ? proxy_set_header X-Real-IP $remote_addr;
? ? ? ? proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
? ? }
}

nginx测试配置文件:

nginx -t

[root@li433-14 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

reload nginx配置:

systemctl reload nginx.service

再次访问80端口,如果正常及表示反向代理配置已成功!

链接到文章: https://jiloc.com/42378.html

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注