Flask+Gunicorn+Nginx配置多个app
请自行安装好nginx、gunicorn和flask的运行环境,这里不再赘述
Nginx配置
修改nginx的配置
vi /etc/nginx/sites-available/default
//default
server {
listen 80;//监听80端口
server_name www.ikiyomi.cc;
access_log /root/web/logs/nginx_app.log;
//转发第一个app的请求
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header host $http_host;
proxy_pass http://127.0.0.1:5000;
}
//转发第二个app的请求
location /weixin {
proxy_pass http://127.0.0.1:5001;
}
}
测试配置文件是否产生错误
nginx -t
开启服务
service nginx start
Flask app配置
将两个app运行的端口与nginx定义的端口一致,本地运行
//app_1
if __name__ == '__main__':
app.run(debug=False, port=5000)
# 127.0.0.1:5000
//app_2
if __name__ == '__main__':
app.run(debug=False, port=5001)
# 127.0.0.1:5001
Gunicorn配置
Gunicorn配置文件
//gunicorn_app1.conf
//配置方式相似,以app_1为例
# 绑定5000端口,与Flask端口一致
bind = "127.0.0.1:5000"
# 线程数
workers = 3
backlog = 2048
worker_class = "gevent"
# debug = True
proc_name = "gunicorn.pid"
pidfile = "/tmp/gunicorn.pid"
# logfile = "/root/wechat/logs/20161019.log"
accesslog = "/root/wechat_web/logs/gunicorn.log"
loglevel = "debug"
# 是否以守护进程方式运行
daemon = True
运行Gunicorn
gunicorn -c gunicorn_app1.conf app_1:app
参数说明:
- -c 以配置文件方式运行
- app_1 文件名
- app app名
查看gunicorn守护进程是否运行
ps aux | grep gunicorn
作者:ioiogoo
链接:https://www.jianshu.com/p/040b9446acd2
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
Flask+Gunicorn+Nginx配置多个app的更多相关文章
- 基于flask+gunicorn+nginx来部署web App
基于flask+gunicorn&&nginx来部署web App WSGI协议 Web框架致力于如何生成HTML代码,而Web服务器用于处理和响应HTTP请求.Web框架和Web服务 ...
- 【新手向】阿里云上ubuntu+flask+gunicorn+nginx服务器部署(二)项目部署
本项目实现的是类似于ins的图片分享网站.继续(一),当nginx的配置已修改好后,要在远程服务器上部署网站,只需要几个步骤: 1 前期准备 2 将运行网站的代码从github上下载过来 3 下载依赖 ...
- gunicorn+nginx配置方法
对于gunicorn+nginx的配置,理解他们之间的关系很重要,以及最后如何确认配置结果是正确的也很重要 nginx 配置文件: 修改这个配置文件有3个用处: 假设服务器本身的Ip是A称为ip-A, ...
- flask+gunicorn+nginx部署
安装nginx和gunicorn yum install nginx pip3 install gunicorn flask项目配置 #main.py from flask import Flask ...
- 【flask】使用配置类管理app测试环境-demo版
如果对app.config是什么还心有疑惑,或者对于这种配置方式很陌生,参考:flask项目配置 app.config classConfig.py: class BaseConfig(object) ...
- Windows + Python + flup + flask + fastcgi + Nginx配置
Nginx配置 # HTTPS server { listen ssl; server_name kvaccount.xx.io; ssl_certificate "C:/xx/conf/s ...
- Flask + Gunicorn + Nginx 部署
最近很多朋友都在问我关于 Flask 部署的问题,说实在的我很乐意看到和回答这样的问题,至少证明了越来越多人开始用 Flask 了. 之前我曾发表过一篇在 Ubuntu 上用 uwsgi + ngin ...
- python web开发c6——阿里云上ubuntu+flask+gunicorn+nginx服务器部署(一)简单测试
简述 Nginx在服务器部署中的作用 请求通过Nginx实现反向代理,将请求提交给代理服务器.本文中只用了一台服务器,所以是代理到本机. gunicorn的作用 作为服务器代码的容器.接收Nginx的 ...
- Ubuntu | Flask + Gunicorn + Nginx 部署服务器环境
现在我们手里有一个准备发布的项目,那么如何将他上传到你的服务器,并让外网访问呢? 前提: 1. 安装了Python环境 apt-get install python-dev 2. 安装Flask pi ...
- Centeos7部署Flask+Gunicorn+nginx
一.环境安装 pip3 install flask pip3 install gunicorn pip3 install nginx 二.模块介绍 1.Flask是一个使用 Python 编写的轻量级 ...
随机推荐
- 更多Linux实用命令
更多实用命令 进程相关 当程序运行在系统上时,我们称之为进程(process).想监测这些进程,需要熟悉 ps/top 等命令的用法.ps 命令好比工具中的瑞士军刀,它能输出运行在系统上的所有程序的许 ...
- 去除input框相关样式,只显示内容
<input /> css代码: .edit-input{ /* width: 20px; */ height: -webkit-fill-available; background: i ...
- SDN实验1
(一)基本要求 使用Mininet可视化工具,生成下图所示的拓扑,并保存拓扑文件名为学号.py. 使用Mininet的命令行生成如下拓扑: a) 3台交换机,每个交换机连接1台主机,3台交换机连接成一 ...
- 通过前端导出excel表格
1. 在前端HTML上绘制想要导出的表格(包含后端获取的数据) <div class="exportExcel" id="exportOutTable" ...
- sqlite bundle 的含义,和 sqlite.dll, SQLite.Interop.dll, System.Data.SQLite.dll 三者之间的关系
sqlite bundle 的含义,和 sqlite.dll, SQLite.Interop.dll, System.Data.SQLite.dll 三者之间的关系. bundle 表示不需要配合 S ...
- 在DeepIn系统中使用eclipse创建maven的Web项目
1. 安装好jdk和eclipse以后,启动eclipse 2. 创建maven项目,选择Maven Project 3. 在创建项目过程中,创建简单Maven项目,不使用archetype创建(会联 ...
- Unity泛型单例模式
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Singleto ...
- Jsp 总结
JSP中的include的两种用法 1.两种用法 <@inlcude file ="header.jsp"/> 此时引入的是静态的jsp文件,它将引入的jsp中的源代码 ...
- 【BUUCTF】ACTF2020 新生赛Include1 write up
查看源代码+抓包都没有发现什么信息,只有这两个东东 <meta charset="utf8"> Can you find out the flag? <meta ...
- JDK 7 HashMap 并发情况下的死锁问题
目录 问题描述 详细解释 问题描述 JDK7的 HashMap 解决冲突用的是链表,在插入链表的时候用的是头插法,每次在链表的头部插入新元素.resize() 的时候用的依然是头插,头插的话,如果某个 ...